相关疑难解决方法(0)

禁用UIWebView中的用户选择

我有一个应用程序,我将内容加载到一个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开始

webkit uiwebview mobile-webkit ios4 ios

118
推荐指数
9
解决办法
9万
查看次数

禁用WebView上文本字段中的复制和粘贴菜单.我的应用程序基于IOS Phonegap.

我的应用程序是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)

但我无法禁用双击.任何人具有相同的查询?帮帮我...

webview ios long-press cordova

3
推荐指数
1
解决办法
2755
查看次数

标签 统计

ios ×2

cordova ×1

ios4 ×1

long-press ×1

mobile-webkit ×1

uiwebview ×1

webkit ×1

webview ×1