How to disable Copy and Paste in UIWebView

前端 未结 6 926
再見小時候
再見小時候 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:53

    You can try injecting javascript into the webView. This code works on the iPhone too but only when the page is fully loaded. http://javascript.internet.com/page-details/disable-text-selection.html or http://solidlystated.com/scripting/proper-way-to-disable-text-selection-and-highlighting/

    To get it to work properly when the page is only half loaded or still loading you'll proably have to use a setup similar to this one where you inject the disabling javascript just as it would start selecting. http://www.icab.de/blog/2010/07/11/customize-the-contextual-menu-of-uiwebview/

    UIWebView without Copy/Paste and selection rectangle when showing documents

提交回复
热议问题