iphone - 点击手势识别器不适用于 UIView 内部的 UIScrollView 中的 UIWebiew

标签 iphone ios ipad ios5 ios4

我已将 WebView 放置在 Scrollview 中,而 Scrollview 又放置在 viewcontroller 的 View 中。 在 webview 上点击时,不会调用“tapRecognized”方法。

这是我的代码:

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

    [oneFingerTwoTaps setNumberOfTapsRequired:1];


// Add the gesture to the view

[[self view] addGestureRecognizer:oneFingerTwoTaps];

我也试过 foll :

[scrollview addGestureRecognizer:oneFingerTwoTaps];

[webview addGestureRecognizer:oneFingerTwoTaps];

请帮忙

最佳答案

尝试添加以下语句:

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

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

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

希望对你有帮助

关于iphone - 点击手势识别器不适用于 UIView 内部的 UIScrollView 中的 UIWebiew,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10162029/

相关文章:

ios - 如何在 INSendPaymentIntent 中选择电话号码

iphone - 核心数据不保存我的数据。应用程序关闭后我丢失了所有保存的数据

ios - Swift 3 转换得到 'Int1' 不能转换为 'Bool'

css - CSS 中指定的背景图像不会出现在 iPad 中

android - 在 iPad 和 Android 上大延迟执行声音

iphone - ios iphone 开发中的 Relativelayout 或 LinearLayout?

iphone - 多选分段控件

iOS 布局 : push UIView below automatically

javascript - 如何从 react-native webview 获取选择对象

ios - 谷歌地图不适合 subview