如何在 ios7 的 UITextfield 中禁用复制/粘贴选项 [英] How to disable copy/paste option in UITextfield in ios7
本文介绍了如何在 ios7 的 UITextfield 中禁用复制/粘贴选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试过了
@implementation UITextField (DisableCopyPaste)
-(BOOL)canPerformAction:(SEL)action withSender:(id)sender
{
return NO;
return [super canPerformAction:action withSender:sender];
}
@end
但是它禁用了所有文本字段的复制/粘贴选项,如何禁用特定文本字段的菜单选项.
But it disables all textfield's copy/paste option,how to disable the menu options for specific textfield.
推荐答案
我觉得这个方法还行,因为没有做category等,对我来说很好用.
I think this method is ok,since no making of category etc.It works fine for me.
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
[[UIMenuController sharedMenuController] setMenuVisible:NO animated:NO];
}];
return [super canPerformAction:action withSender:sender];
这篇关于如何在 ios7 的 UITextfield 中禁用复制/粘贴选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文