Skip to content

Instantly share code, notes, and snippets.

@Krumelur
Created June 18, 2015 15:44
Show Gist options
  • Save Krumelur/353f7ca57d1010725c12 to your computer and use it in GitHub Desktop.
Save Krumelur/353f7ca57d1010725c12 to your computer and use it in GitHub Desktop.
Shows how to detect any touch of the iOS screen
public class Application
{
// This is the main entry point of the application.
static void Main(string[] args)
{
UIApplication.Main(args, typeof(CustomApplication), typeof(AppDelegate));
}
}
// Inherits from UIApplication
public class CustomApplication : UIApplication
{
// This gets called for various system events.
public override void SendEvent (UIEvent ev)
{
base.SendEvent (ev);
//Check if the screen was touched. This will always be called, no matter what view controller is currently on screen.
UITouch anyTouch = ev.AllTouches != null ? ev.AllTouches.AnyObject as UITouch : null;
if(anyTouch != null && anyTouch.TapCount > 0 && anyTouch.Phase == UITouchPhase.Began)
{
// TODO: Update some static variable or database value to store the current time of the touch
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment