UITextField no longer reloads keyboardType after reloadInputViews call

前端 未结 2 2261
太阳男子
太阳男子 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.

    0 讨论(0)
  • 2021-02-20 12:38

    I found that this works when the textfield is first responder:

    [self.textField reloadInputViews];
    [self.textField setText:@" "];
    [self.textField setText:@""];
    
    0 讨论(0)
提交回复
热议问题