views:

98

answers:

1

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

}

+1  A: 

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.

ta.faris
Weird. I was working on something unrelated with a sort of view that "pops up" over a web view. I had it set the underlying web view's [setUserInterActionEnabled: NO], when I do that, and tapped the screen, the handleTap function kicked in. Looks like web view ignores taps but not swipes. Probably to keep links, etc, running properly?
Chris
Sounds almost like your recognizers are added to the view that pops up. I'm working on a project currently where tap AND swipe recognizers are both added directly to a webview (as in [webview addGestureRecognizer: tapper]) and they seem to work every time.
ta.faris
Hmm, I will keep exploring. The tap recognizer is not added to the pop-up view. It only works when you tap outside of the border, in the larger area. However other interactions in the larger area (links, etc.) are still disabled.
Chris