My UIView contains Two UITextField.I need to restrict copy,paste option for one textfield.I don't want to restrict that for another.
When i am using the following code,Both the field gets restricted from copy,paste.
-(BOOL)canPerformAction:(SEL)action withSender:(id)sender
{
if ( [UIMenuController sharedMenuController] )
{
[UIMenuController sharedMenuController].menuVisible = NO;
}
return NO;
}
Can any one provide me the solution to solve my problem.
Create a subclass of UITextField. In that subclass, implement
- (BOOL)canPerformAction:(SEL)action withSender:(id)sender { if (sel_isEqual(action, @selector(copy:))) { return NO; } return [super canPerformAction:action withSender:sender]; }
Then use this subclass for the field that you don't want to be able to copy in, and use a regular UITextField for the one that you can copy from.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With