我试过了
@implementation UITextField (DisableCopyPaste) -(BOOL)canPerformAction:(SEL)action withSender:(id)sender { return NO; return [super canPerformAction:action withSender:sender]; } @end
但它禁用所有textfield的复制/粘贴选项,如何禁用特定文本字段的菜单选项.
解决方法
我认为这种方法没问题,因为没有制作类别等.对我来说这很好.
[[NSOperationQueue mainQueue] addOperationWithBlock:^{ [[UIMenuController sharedMenuController] setMenuVisible:NO animated:NO]; }]; return [super canPerformAction:action withSender:sender];