How to disable copy,paste options in UITextView and enable it again iPhone app?

痴心易碎 提交于 2019-12-11 16:29:57

问题


Am working in UITextView based iPhone app. In one of my screen i having 3 UITextView when the user tap on the screen am showing UIMenuController with custom MenuItems. In this scenario UITextView is in Active means UITextView is becomResponder. So when i show UIMenuItem taping the screen UITextView UIMenuController showing with "Paste" option.

I want to disable UIMenuController item from UITextView when the user touches the screen. Could you please anyone tell me how to disable UITextView with showing keypad and disable UIMenuController.? Thanks in advance.


回答1:


You can Code like this:

-(BOOL)canPerformAction:(SEL)action withSender:(id)sender
{
    if (action == @selector(paste:))
        return NO;
    return [super canPerformAction:action withSender:sender];
}

other wise you can write:

- (BOOL)canBecomeFirstResponder {
    return NO;
}

To make your textfiled noneditable. Hope it works for you.



来源:https://stackoverflow.com/questions/12990043/how-to-disable-copy-paste-options-in-uitextview-and-enable-it-again-iphone-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!