Search code examples
iphoneobjective-ciosuiwebview

Get touchesBegan on a subview (UIWebView)


I've an UIWebView which is added as a subview in a UIview and I would like to detect when this UIWebView is touched but touchesBegan just don't work.

Any idea ?


Solution

    1. Subclass UIWebView in your code and then implement touchesBegan in your class.
    2. Add the subclassed webview as a subview of your UIView.
    3. Call super in the subclassed UIWebView

      - (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event 
      {
          [super touchesBegan: touches withEvent: event];
      }