ITeye博客

iso UIWebView 禁用复制

dokero · 2015-11-18 16:40 · ios · 移动开发 · Markdown

为项目需要,需要在使用UIWebView载入html时,禁用在input中的copy paste Menu选项 修改Html页面 方法一: function OnLoad() { document.documentElement.style.webkitTouchCallout = "none"; //禁止弹出菜单 document.documentElement.style.webkitUserSelect = "none";//禁止选中 } 然后在body加上onload 实际测试,input并未禁止弹出复制、粘贴功能 html页面内容,禁止了复制功能 方法二: 实际测试,禁止了弹出复制、粘贴功能,但键盘输入也无法在显示在webView的input中。 修改iOS代码: 方法一: - (void)webViewDidFinishLoad:(UIWebView *)webView { // Disable user selection [webView stringByEvaluatingJavaScriptFromString:@"document.documentElement.style.webkitUserSelect='none';"]; // Disable callout [webView stringByEvaluatingJavaScriptFromString:@"document.documentElement.style.webkitTouchCallout='none';"]; } 实际测试,input并未完成禁止弹出复制、粘贴功能 html页面内容,禁止了复制功能 方法二: 获得UIMenuController,然后强行隐藏menu item的view, 实际测试,有效果,估计不能提交到app store

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。