Hide the cursor of an UITextField

后端 未结 13 820
甜味超标
甜味超标 2020-12-07 07:51

I am using a UITextField with a UIPickerView for its inputView, so that when the user taps the text field, a picker is summoned for th

13条回答
  •  一整个雨季
    2020-12-07 08:44

    To both disable cursor and menu I use subclass with these 2 methods:

    - (CGRect)caretRectForPosition:(UITextPosition *)position {
        return CGRectZero;
    }
    
    - (BOOL)canPerformAction:(SEL)action withSender:(id)sender {
        [UIMenuController sharedMenuController].menuVisible = NO;
        self.selectedTextRange = nil;
    
        return NO;
    }
    

提交回复
热议问题