Reputation: 58067
I have a menu which I'd like to have automatically hide if it's inactive after a certain amount of time. This menu is composed of a hierarchy of UIViewControllers, which present various different views.
I'm thinking along the lines of running a timer, which invalidates and starts over whenever there's a touch.
Is it possible to catch all touch events in a set of UIViews? Perhaps just keep a boolean lying around and use the main UIWindow to catch touch events?
EDIT:
My app is a kiosk app of sorts, with a main screen and a menu. When the menu is up, I want it to run an auto dismiss timer, which resets after any touch in the entire menu screen. The menu is displayed over the entire screen, modally.
Upvotes: 2
Views: 1176
Reputation: 1036
You can have an invisible view on top of your modals view controllers, and put have either a gesture recognizer on it which can start a timer, either a
-touchesBegan:withTouches
method, and then send to the .nextResponder
the same method.
Upvotes: 0
Reputation: 1542
One way to be sure is to subclass UIApplication
and override - (void)sendEvent:(UIEvent *)event
method, every touch event happening in your app goes through this method and you can check the UIEvent
type to see if it's UIEventTypeTouches
and reset the timer.
Another way to do this simply involves adding a transparent layer over whole user accesible UI and override hitTest:withEvent:
.
Upvotes: 2