iOS版。如何将触摸传递给UIWebView的父视图

时间:2011-03-30 04:54:13

标签: iphone uiwebview touch

我有一个userInteractionEnabled=YES的UIWebView。它拦截所有触摸并且不会将任何触摸传递给父视图。有没有简单的方法让它传递到父视图?

2 个答案:

答案 0 :(得分:0)

你可以那样做

- (void) touchesBegan: (NSSet *) touches withEvent: (UIEvent *) event {

    //call your parent controller touchesBegan
    [parent touchesBegan: touches withEvent: event];
}

- (void) touchesMoved: (NSSet *) touches withEvent: (UIEvent *) event {

        //call your parent controller touchesMoved
        [parent touchesMoved: touches withEvent: event];
}

- (void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {

    //call your parent controller touchesEnded
    [parent touchesEnded: touches withEvent: event];
}

答案 1 :(得分:0)

我找到this article,其中说:

  

通过Web视图捕获触摸有多种方法。一种是扩展UIWebView类,但Apple说你不应该这样做,所以我们将远离该解决方案以防以后出现问题。相反,我们将扩展UIWindow类,并在它们传播到正确的视图之前捕获触摸事件。

它继续描述如何使用示例代码完成此操作。有关详细信息,请参阅http://wyldco.com/blog/2010/11/how-to-capture-touches-over-a-uiwebview/