Disable text selection UITextView

前端 未结 3 2014
攒了一身酷
攒了一身酷 2021-01-17 01:48

I want to disable text selection on a UITextView. Until now what i\'ve already done is:

- (BOOL)canPerformAction:(SEL)action withSender:(id)sender {   
           


        
3条回答
  •  一生所求
    2021-01-17 02:47

    If you want to disable cut/copy/paste on all UITextView of your application you can use a category with :

    @implementation UITextView (DisableCopyPaste)
    
    - (BOOL)canBecomeFirstResponder
    {
        return NO;
    }
    
    @end
    

    It saves a subclassing... :-)

    Otherwise, just subclass UITextViewand put :

    - (BOOL)canBecomeFirstResponder
    {
        return NO;
    }
    

提交回复
热议问题