I have a UITableViewController
class in which I'd like to return to the root view controller after an amount of inactivity. I'm assuming inactivity to mean no activity (taps, touches, drags, scrolls) have occurred anywhere on the screen in the past X minutes. I tried using a UITapGestureRecognizer
to detect screen activity however it is not consistent, sometimes firing an event, sometimes not. Also, it only fires when there is an actual 'tap' on the display. I basically want to know whenever the display detects finger activity of any kind. How can I do this? The code below is how I've implemented the Gesture Recognizer.
- (void)viewDidLoad
{
[super viewDidLoad];
NSLog(@"viewdidLoad");
mItems = [[NSArray alloc] initWithObjects:@"foo", @"bar", @"baz", @"bin", @"boo", nil];
// watch for touches anywhere to reset main menu timeout
UITapGestureRecognizer *tr = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapperEvent:) ];
[self.tableView addGestureRecognizer:tr];
}
...
- (void) tapperEvent:(UITapGestureRecognizer *)tapper
{
NSLog(@"tap event fired");
}