一、网上方案
- (void)webViewDidFinishLoad:(UIWebView*)theWebView
[self.webView stringByEvaluatingJavaScriptFromString:@"document.documentElement.style.webkitUserSelect='none';"];
[self.webView stringByEvaluatingJavaScriptFromString:@"document.documentElement.style.webkitTouchCallout='none';"];
- 注释: 这个方案只能去除掉单页面应用, 既js里面没有打开两个页面.而且一些特殊的手势还是会触发弹框.
二、手势方案
- (void)webViewDidFinishLoad:(UIWebView*)theWebView
for (UIView *subView in self.webView.scrollView.subviews) {
for (UIGestureRecognizer *gesture in subView.gestureRecognizers) {
gesture.delegate = self;
}
}
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer {
if ([gestureRecognizer isKindOfClass:[UILongPressGestureRecognizer class]] || [gestureRecognizer isKindOfClass:NSClassFromString(@"UITapAndAHalfRecognizer")]) {
return NO;
}
NSLog(@"gestureRecognizerShouldBegin == %@",NSStringFromClass([gestureRecognizer class]));
return YES;
}
- 就是禁止掉UILongPressGestureRecognizer长按手势和UITapAndAHalfRecognizer系统的这个手势, 太坑了,测试半天才找到这个凶手
网友评论