SoFunction
Updated on 2025-04-12

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

Preface

In the hybrid mode development of APP, there is WebView as a bridge for hybrid mode development in Android development. Of course, there is also a UIWebView component in IOS to serve as a bridge for hybrid mode development. Developers who have used UIWebView components know that when UIWebView loads and displays HTML pages, the component itself provides some system default interaction behavior. This article shares with you the iOS UIWebView implements the function of prohibiting users from copying and cutting. Let's take a look together.

Sample code

// 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 entire content of this article. I hope the content of this article will be helpful to all iOS developers. If you have any questions, you can leave a message to communicate.