0

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 !

ketansahasrabudhe
  • 119
  • 1
  • 3
  • 8

1 Answers1

1

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

Community
  • 1
  • 1
rishi
  • 11,779
  • 4
  • 40
  • 59
  • Subclassing is not a good option as i had mentioned earlier as well.It is mentioned in the developer docs as well. You can try this which is in one of threads above - http://mithin.in/2009/08/26/detecting-taps-and-events-on-uiwebview-the-right-way/ – rishi Jun 29 '12 at 09:52
  • the link which you have provide that uses `(void)sendEvent:(UIEvent *)event` and this method is deprecated after iOS 5.0 and i am using iOS 5.1 – ketansahasrabudhe Jun 29 '12 at 10:00
  • We are not here to do code for you? you need to do that yourself, we can just help you if you are stuck anywhere? – rishi Jun 29 '12 at 10:04
  • dude i am telling because i am very new here and i really don't know how to do this, and tutorial you have provided is deprecated so i told you to do this small thing. if you can then it will be really appreciated. – ketansahasrabudhe Jun 29 '12 at 10:08