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

StackOverflow https://stackoverflow.com/questions/21905725

문제

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

enter image description here

도움이 되었습니까?

해결책

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];
}

다른 팁

You can play with this property:

enter image description here

and this one :

enter image description here

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];
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top