Question

Very strange. I have implemented a number of swipe gesture recognizers, all working fine. I just added a tap gesture recognizer, though, and when I run the simulator and click I get no effect. In the following code, [self doMethod] will never fire. I set up all the gesture recognizers in viewDidLoad for my controller. I am using a UIWebView, so there might be some funkiness there. Any Ideas?

I set up the recongnizer normally:

UITapGestureRecognizer *tapper = [[UITapGestureRecognizer alloc]initWithTarget:self        action:@selector(handleTap:)];
[self.view addGestureRecognizer:tapper];

The handleTap method.

-(IBAction)handleTap:(UITapGestureRecognizer*)sender{
    [self doMethod];
}
Was it helpful?

Solution

I'm not 100% sure of what the defaults of the "numberOfTapsRequired" and "numberOfTouchesRequired" properties for UITapGestureRecognizer are, but you may want to try initializing those and see if that kicks it into gear. Also if your UIWebView is covering the entire view the touches may not ever be received by the bottom view (again, not 100% sure). You may try adding the recognizers to the webview.

OTHER TIPS

This should work

-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
    return YES;
}

UIWebView has its own gestureRecognizers

This says to UIWebView that we are going to use aditional gestureRecognizers

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top