How to disable popup menu items like Select, Select All, Suggest..., Define (on UIWebView
)?
Swizzle the following method:
#import "NSObject+myCanPerformAction.h"
@implementation NSObject (myCanPerformAction)
- (BOOL)myCanPerformAction:(SEL)action withSender:(id)sender {
if (action == @selector(copy:)) {
return [self myCanPerformAction:action withSender:sender]; // not a recursion
}
if (action == @selector(paste:)) {
return [self myCanPerformAction:action withSender:sender]; // not a recursion
}
return NO;
}
@end
Swizzling:
[[UIWebDocumentView class] jr_swizzleMethod:@selector(canPerformAction:withSender:) withMethod:@selector(myCanPerformAction:withSender:) error:nil];