Hide Input Keyboard on iPhone Without Knowing First Responder?

后端 未结 3 1692
不知归路
不知归路 2021-01-04 19:30

I have seen this question, but the question is how to know which textView is the first responder? This question looked promising to figure out the first responder, but it tu

3条回答
  •  臣服心动
    2021-01-04 19:50

    I believe you should pick something to become the first responder, something which probably doesn't do anything on its own, and call -[UIResponder becomeFirstResponder] on it. This would work well with a UIViewController or UIWindow (which you can get through -[UIView window], I think) because these would have the most similar responder chains, and would make the current firstResponder loose its firstResponder status, dismissing the keyboard, but also wouldn't bring up the keyboard, as it would not be a UITextField.

提交回复
热议问题