How to disable Copy and Paste in UIWebView

前端 未结 6 907
再見小時候
再見小時候 2020-12-09 13:17

When a user long-press inside UIWebView, there is a Copy & Paste popup. Is it possible to disable the system from popup the Copy & Paste function, but still allow th

6条回答
  •  一向
    一向 (楼主)
    2020-12-09 13:49

    i hope this work for you, because is work for me

    - (void)webViewDidFinishLoad:(UIWebView *)webView
    {
        [webView stringByEvaluatingJavaScriptFromString:@"document.body.style.webkitTouchCallout='none';"];
        [webView stringByEvaluatingJavaScriptFromString:@"document.body.style.webkitUserSelect='none';"];
    }
    

提交回复
热议问题