Disable UITextField keyboard?

后端 未结 10 2170
不知归路
不知归路 2020-11-27 15:42

I put a numeric keypad in my app for inputing numbers into a text view, but in order to input numbers I have to click on the text view. Once I do so, the regular keyboard co

10条回答
  •  执念已碎
    2020-11-27 16:20

    I have the same problem when had 2 textfields on the same view. My purpose was to show a default keyboard for one textfield and hide for second and show instead a dropdown list.

    - (BOOL)textFieldShouldBeginEditing:(UITextField *)textField 
    

    method simply did not work as I expected for 2 textfields , the only workaround I found was

        UIView* dummyView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 1, 1)];    
        myTextField.inputView = dummyView; 
        myTextField.inputAccessoryView = dummyView; 
        myTextField.tintColor =  myTextField.backgroundColor; //to hide a blinking cursor
    

    This will totally hide the keyboard for a target textField (DropDownList in my case) and show a default one when user switches to the 2nd textfield (Account number on my screenshot)

提交回复
热议问题