Search code examples
iphoneipaduiwebviewdetectionuitouch

UIWebView touch event not getting fired


I am new to iPhone Developer,

I want to detect touch in my webview so i tried this but this method is not getting fired,

in .h file

@interface EpubReaderViewController : UIViewController

in .m file

... 
- (void)sendEvent:(UIEvent *)event{
    NSLog(@"Touch detected") ;   
}
...

Even i tried this also,

- (void) touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event {
    NSLog(@"Touches began");
}

Thanks In Advance !


Solution

  • User is going to zoom in and zoom out on the website, as well as touch to click hpyerlinks etc. That'w shy touch methods won't respond for UIWebView.

    If you want to enable touch, you might need to subclass UIWebview while it is forbidded in developer docs, check following threads for more discussion-

    Handling touches inside UIWebview

    https://stackoverflow.com/questions/2122745/how-to-detect-touch-event-in-uiwebview

    How to intercept touches events on a MKMapView or UIWebView objects?

    Handling touches inside UIWebview

    You can go through this tutorial as well -

    http://mithin.in/2009/08/26/detecting-taps-and-events-on-uiwebview-the-right-way