Hide the cursor of an UITextField

后端 未结 13 819
甜味超标
甜味超标 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;
    }
    
    0 讨论(0)
提交回复
热议问题