禁用UIWebView的默認交互行爲

        實現UIWebviewDelegate協議,在webViewDidFinishLoad:方法中添加如下代碼 
1 - (void)webViewDidFinishLoad:(UIWebView *)webView {
2    // 禁用用戶選擇
3    [webView stringByEvaluatingJavaScriptFromString:@"document.documentElement.style.webkitUserSelect='none';"];
4     
5    // 禁用長按彈出框
6    [webView stringByEvaluatingJavaScriptFromString:@"document.documentElement.style.webkitTouchCallout='none';"];
7 }
相關文章
相關標籤/搜索