How to disable keyboard appearing when hitting on a text field , iOS?

后端 未结 8 1343
日久生厌
日久生厌 2021-02-07 19:50

I have a text field , and i need when the user presses it to show a custom picker.

The picker is shown fine , but the problem is that the keyboard appears on the bottom

相关标签:
8条回答
  • 2021-02-07 20:40

    Use textfield delegate.

    -(BOOL)textFieldShouldBeginEditing:(UITextField *)textField
    {        
        return NO;
    }
    
    0 讨论(0)
  • 2021-02-07 20:45
    - (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
    {
        if(textfield == yourtextField)
        {
            [textfield resignFirstResponder];
            // Show you custom picker here....
            return NO;
        }     
    }
    

    and you need to implement the uitextfielddelegate in the controller.

    and give assign the delegate to yourtextField.

    0 讨论(0)
提交回复
热议问题