Is there a way to block copy / paste from a text view?

I need a way to deactivate automatic selection from a UITextView .

alt text

I unselected all attributes from the interface constructor, but when I touch the text, a choice will appear!

Is there a solution? Magic tricks?

thank.

+3
source share
2 answers

You need to subclass UITextView and override the canPerformAction method.

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

Selector values ​​that can be expected from canPerformAction can be found in the UIResponderStandardEditActions Protocol Link

A reference to the UIResponder class will also help.

canPerformAction: withSender:

, , . ; , , . YES, .

+5

UIResponder

, UITextView, canPerformAction:withSender: "NO" , .

0

Source: https://habr.com/ru/post/1783919/


All Articles