iOS UIWebView implements the function of prohibiting users from copying and cutting

  • 2021-07-22 11:37:02
  • OfStack

Preface

In the mixed mode development of APP, In Android development, WebView is used as a bridge for mixed mode development, Of course, there is also an UIWebView component in IOS as a bridge for mixed mode development. Developers who have used UIWebView components know that when UIWebView loads and displays HTML pages, the component itself provides some default interactive behaviors of the system. What this article shares with you is that iOS UIWebView implements the function of prohibiting users from copying and cutting. Let's take a look at it.

Sample code


//  The controller implements this method 
- (BOOL)canPerformAction:(SEL)action withSender:(id)sender
{
 if (action == @selector(copy:) ||
  action == @selector(paste:)||
  action == @selector(cut:))
 {
  return NO;
 }
 return [super canPerformAction:action withSender:sender];
}

Summarize

The above is the whole content of this article. I hope the content of this article can be helpful to all iOS developers. If you have any questions, you can leave a message for communication.


Related articles: