gpt4 book ai didi

iphone - 处理 UIWebview 内的触摸

转载 作者:行者123 更新时间:2023-12-03 18:14:12 26 4
gpt4 key购买 nike

我创建了 UIWebView 的子类,并实现了touchesBegantouchesMovedtouchesEnded 方法。

但是 webview 子类不处理 touch 事件。

UIWebView 子类中是否有处理触摸事件的方法???

最佳答案

无需子类化,只需添加 UITapGestureRecognizer :

UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didTapMethod)];
[tap setNumberOfTapsRequired:1]; // Set your own number here
[tap setDelegate:self]; // Add the <UIGestureRecognizerDelegate> protocol

[self.myWebView addGestureRecognizer:tap];

添加 <UIGestureRecognizerDelegate>在头文件中添加协议(protocol),并添加此方法:

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

关于iphone - 处理 UIWebview 内的触摸,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/990870/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com