Hide the cursor of an UITextField

后端 未结 13 846
甜味超标
甜味超标 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:32

    Answer provided by the OP, copied from the question body to help clean up the ever growing tail of unanswered questions.

    I found another solution: subclass UIButton and override these methods

    - (UIView *)inputView {
        return inputView_;
    }
    
    - (void)setInputView:(UIView *)anInputView {
        if (inputView_ != anInputView) {
            [inputView_ release];
            inputView_ = [anInputView retain];
        }
    }
    
    - (BOOL)canBecomeFirstResponder {
        return YES;
    }
    

    Now the button, as a UIResponder, have a similar behavior than UITextField and an implementation pretty straightforward.

提交回复
热议问题