In my ViewController's header file I have:
@interface CaseStudyChoiceViewController : UIViewController <UIWebViewDelegate>
@property (strong, nonatomic) IBOutlet UIWebView *myWebView;
@end
Then in the .m file in the ViewDidLoad method:
[_myWebView setDelegate:self];
and finally:
#pragma mark - WebView Delegate Methods
-(BOOL)canPerformAction:(SEL)action withSender:(id)sender
{
if (action == @selector(copy:) ||
action == @selector(paste:) ||
action == @selector(select:) ||
action == @selector(cut:) ||
action == @selector(selectAll:))
{
NSLog(@"Selector is %@", NSStringFromSelector(action));
return NO;
}
else
{
return [super canPerformAction:action withSender:sender];
}
//I tried the code below as well and got the same result
/*
UIMenuController *menuController = [UIMenuController sharedMenuController];
if (menuController)
{
[UIMenuController sharedMenuController].menuVisible = NO;
}
return NO;
*/
}
The problem I have is that this will NOT disable the Copy function. When I run this the NSLog output is:
2013-12-30 21:39:28.794 PCO - CLS[45238:70b] Selector is cut:
2013-12-30 21:39:28.794 PCO - CLS[45238:70b] Selector is select:
2013-12-30 21:39:28.795 PCO - CLS[45238:70b] Selector is selectAll:
2013-12-30 21:39:28.795 PCO - CLS[45238:70b] Selector is paste:
copy: is never presented in the canPerformAction method. Any ideas on where I can capture it?
The end result here is that when the user does a long touch in the UIWebView two options pop up, Copy and Define. I only want Define.