我有一个应用程序,我将内容加载到一个UIWebView并呈现此.我无法完全禁用用户交互,因为我希望用户能够单击链接.我只需要禁用用户选择.我发现你可以使用的互联网中的某个地方:
document.body.style.webkitUserSelect='none';
Run Code Online (Sandbox Code Playgroud)
我试着插入这个
[self.contentView stringByEvaluatingJavaScriptFromString:@"document.body.style.webkitUserSelect='none';"];
Run Code Online (Sandbox Code Playgroud)
在 webViewDidFinishLoad:
但是,它不起作用.我仍然可以在WebView中选择和复制文本.
什么想法可能会出错?
更新:这似乎只从iOS 4.3开始
我的应用程序是ios phonegap应用程序.我想从Web视图的文本字段中禁用复制和粘贴菜单.长按和双击,复制粘贴菜单显示.我尝试使用UIGestureRecognizer类禁用长按和双击:
- (void)viewDidLoad{
UILongPressGestureRecognizer* longPressGesture = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(gestureHandler:)];
[longPressGesture setMinimumPressDuration:0.2];
longPressGesture.delegate = self;
[self.webView addGestureRecognizer:longPressGesture];
}
-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
if ([gestureRecognizer isKindOfClass:[UILongPressGestureRecognizer class]]) {
return NO;
}
else if([gestureRecognizer isKindOfClass:[UITapGestureRecognizer class]]){
return NO;
}
else
return YES;
}
Run Code Online (Sandbox Code Playgroud)
但我无法禁用双击.任何人具有相同的查询?帮帮我...