How to remove the โ€œCopyโ€ option from โ€œshareโ€ in UIMenuController on IOS9?

I have a UITextView in which I load some text. Before iOS 9, I removed the copy option when you select the text inside this text box. I did this by subclassing it and doing the following:

@implementation myCustomClass -(BOOL)canPerformAction:(SEL)action withSender:(id)sender { if (action == @selector(copy:)) { return NO; } return [super canPerformAction:action withSender:sender]; } 

This was enough to remove the "Copy" option. But now in iOS 9, when you select text, the Share button appears, and if you click on it, a new menu will appear, including the option to copy. How to disable the copy option or even disable the Share button?

+7
ios ios9 uitextview
source share
1 answer

Try the following:

 #import "MyTextView.h" @implementation MyTextView - (BOOL)canPerformAction:(SEL)iAction withSender:(id)iSender { SEL shareSelector = NSSelectorFromString(@"_share:"); if (iAction == shareSelector) { return NO; } if (iAction == @selector(copy:)) { return NO; } return [super canPerformAction:iAction withSender:iSender]; } 
+4
source share

All Articles