UITextField no longer reloads keyboardType after reloadInputViews call

前端 未结 2 2260
太阳男子
太阳男子 2021-02-20 12:14

In iOS 7, I could change the keyboard type while it is the firstResponder (on the fly):

if (textField.text.length > 2) {

    textField.keyboardT         


        
2条回答
  •  醉话见心
    2021-02-20 12:21

    I found the same issue. It is better to check whether the textField is already the firstResponder or not.

    [textField reloadInputViews]; // does not work on iOS8 !
    
    if ([textField isFirstResponder]) {
        [textField resignFirstResponder];
        [textField becomeFirstResponder];
    }
    

    Not a clean way though, but it works.

提交回复
热议问题