开发者

iOS UITapGestureRecognizer doing nothing at all?

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];
}


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜