How to disable paste option in menucontroller in iOS?

前端 未结 4 1163
一生所求
一生所求 2021-01-29 00:53

I have to disable Paste option when user long press on UITextField.I have got this code but still it is not hiding Paste option.

-(BOOL)canPerformAction:(SEL)act         


        
4条回答
  •  别那么骄傲
    2021-01-29 01:53

    You have to create a new Class-> subclass of UITextField .. then in your code/xib change the textview class to your Custom Class.. and the add the method in your custom TextField class

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

    It will work then

提交回复
热议问题