In your implementation, you should check if the sender is your exact text field, which should be disabled:
@implementation UITextField (DisableCopyPaste) - (BOOL)canPerformAction:(SEL)action withSender:(id)sender { if ((UITextField *)sender == yourTextField) return NO; return [super canPerformAction:action withSender:self]; } @end
But itβs not good to make a category that redefines a method. It is better if you create a new class, for example SpecialTextField , which inherits UITextField , which will always have a return NO method for canPerformAction: withSender: and set this class only to text fields that should be disabled for copy / paste.
o15a3d4l11s2
source share