Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tap gesture recognizer Not working for UIWebiew inside UIScrollView,which is inside UIView

I've placed the WebView inside a Scrollview, which in turn is placed inside a view of the viewcontroller. When tapping on the webview, "tapRecognized" method is not getting called.

Here's my code :

    UITapGestureRecognizer *oneFingerTwoTaps = 
      [[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapRecognized)] autorelease];

    [oneFingerTwoTaps setNumberOfTapsRequired:1];


// Add the gesture to the view

[[self view] addGestureRecognizer:oneFingerTwoTaps];

I've also tried with the foll :

[scrollview addGestureRecognizer:oneFingerTwoTaps];

[webview addGestureRecognizer:oneFingerTwoTaps];

Please help

like image 713
Saru Avatar asked Apr 15 '12 12:04

Saru


1 Answers

try adding the following statement:

//.h
...
@interface yourclass <UIGestureRecognizerDelegate>
...

//.m
...
[oneFingerTwoTaps setDelegate:self];
...

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

I hope it can help

like image 118
WhiteTiger Avatar answered Sep 25 '22 12:09

WhiteTiger