问题
您可以在WKWebView中选择文本。
期望行为
您应该根本无法在Web视图中选择文本。
我所尝试的
1.使用evaluateJavaScript:completionHandler:
加载NSString * jsCallBack = @"window.getSelection().removeAllRanges();";
1.使用"document.documentElement.style.webkitUserSelect='none'"
执行上述操作
webView.configuration.selectionGranularity = nil;
<--这个没有意义,因为selectionGranularity
只能接受两个预定义的值,但值得一试。
1.尝试在故事板中寻找解决方案,但无法找到不会禁用用户交互的解决方案。
我不能做的事
改变HTML/CSS代码是不是一个选项在这个时候,如果我可以改变它this answer可能会工作。
2条答案
按热度按时间2j4z5cfb1#
半私有灰色区域解决方案依赖于私有Web视图层次结构及其点击手势。作为奖励不依赖于私有类和方法符号,但如果点击手势的顺序会改变,它会打破。
f45qwnt82#