Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Listen to all touch events in an iOS app

Tags:

Is it possible to somehow listen to, and catch, all the touch events occurring in an app?

The app I'm currently developing will be used in showrooms and information kiosks and I would therefore like to revert to the start section of the app if no touches has been received for a given couple of minutes. A sort of screensaver functionality, if you will. I'm planning to implement this by having a timer running in the background, which should be reset and restarted every time a touch event occurs somewhere in the app. But how can I listen to the touch events? Any ideas or suggestions?

like image 919
rodskagg Avatar asked Dec 09 '11 10:12

rodskagg


1 Answers

You need a subclass of UIApplication (let's call it MyApplication).

You modify your main.m to use it:

  return UIApplicationMain(argc, argv, @"MyApplication", @"MyApplicationDelegate");  

And you override the method [MyApplication sendEvent:]:

  - (void)sendEvent:(UIEvent*)event {     //handle the event (you will probably just reset a timer)      [super sendEvent:event]; }  
like image 118
Sulthan Avatar answered Oct 11 '22 01:10

Sulthan