How to disable UITextview selection text, copy/paste UIMenuController but still have hyperlinks working [Not duplicate] [duplicate]

十年热恋 提交于 2019-12-18 02:37:11

问题


I want to disable copy/paste menu and i'm using HTML tag in UITextView in which multiple hyperlinks and want to only disable menu.

My texview image


回答1:


just try to create a subclass of UITextView that overrides the canPerformAction:withSender: method

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



回答2:


You can play with this property:

and this one :




回答3:


You need to create a subclass of UITextView and override the canPerformAction method.

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


来源:https://stackoverflow.com/questions/21905725/how-to-disable-uitextview-selection-text-copy-paste-uimenucontroller-but-still

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