Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITapGestureRecognizer not doing anything

I've got an app that displays a page of text with the ability to tap a button or swipe in a view to advance or retreat through various pages. The container view has two UISwipeGestureRecognizers attached, for swipe left and swipe right. No trouble with these gestures. But now I'm trying to add UITapGestureRecognizer to another view, providing an ability similar to iBooks or the Kindle app, tap the left to go back, the right to go forward. Nothing I do can get the gesture to fire. No hint that it is ever being triggered, even if I put the gesture on my topmost view and disable other gestures.

The view controller implements UIGestureRecognizerDelegate, though I've not needed to implement delegate methods. I did try implementing shouldReceiveTouch: without success.

Here's a snippet of code where I create and attach the gesture recognizer:

UITapGestureRecognizer *recognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapGestureTurnPage:)];
[self.view addGestureRecognizer:recognizer];
[recognizer release];
like image 768
Chris Roberts Avatar asked Jun 25 '11 04:06

Chris Roberts


1 Answers

Try this on the view you're adding the gesture recognizers:

view.userInteractionEnabled = YES;
like image 162
Bogdan Avatar answered Sep 29 '22 20:09

Bogdan