好的,我有一个带有大文本区域的WKWebView,当我点击它时,它会触发这个UIWebTouchEventsGestureRecognizer并显示键盘。
这种行为是正确的。问题是,当从任何其他手势滚动或平移时,会触发此UIWebTouchEventsGestureRecognizer并显示键盘。
有没有办法阻止它?
我正在使用它来获取有问题的手势识别器:
for (UIView* subview in self.subviews) {
// here comes the tricky part, desabling
for (UIView* subScrollView in subview.subviews) {
if ([subScrollView isKindOfClass:NSClassFromString(@"WKContentView")]) {
for (UIGestureRecognizer* gesture in [subScrollView gestureRecognizers]) {
if ([gesture isKindOfClass:NSClassFromString(@"UIWebTouchEventsGestureRecognizer")]) {
gesture.delegate = self;
gesture.delaysTouchesBegan = true;
gesture.delaysTouchesEnded = true;
[gesture requireGestureRecognizerToFail:scrollGesture];
}
}
}
}
}
requireGestureRecognizerToFail:不起作用;
- (BOOL)gestureRecognizer:shouldRequireFailureOfGestureRecognizer:
也没用?
唯一有效的方法是在此委托方法上返回false:
-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {
return false;
}
但显然,现在键盘永远不会显示..
恢复,我需要webview来专注于点击,并忽略平移和其他手势。
任何提示?
答案 0 :(得分:0)
你这个这个吗?
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer