UITextField iOS: how to deal with the dismiss keyboard button?

On the iPhone in Landscape orientation, there is a button in the lower right corner that causes the keyboard to dismiss. I really don't want this button to be there, since I have a Done button already and users should only be able to stop editing the textfield by pressing this Done button (which has to be there to address portrait orientation anyway).

I'm wondering if there's a way to remove that keyboard dismissal button, or if not, I'd appreciate any suggestions for UITextField delegate behavior that differentiates between proper dismissal (Done button pressed) and improper (first responder might resign even though Done button not pressed, eg because of aforementioned problem button or view controller dismissal).


One thing you can do is declare a variable, something like, isDismissedProperly and initiate it to false . Then subscribe to keyboard show and hide notifications. UIKeyboardDidShowNotification and UIKeyboardDidHideNotification . In the target method for done button(as mentioned in the question), change the isDismissedProperly to true. And in the keyboardDidHide method, you can check if isDismissedProperly is true or false.

If it's true, then user dismissed the keyboard by pressing done button.

Hope it helps!

链接地址: http://www.djcxy.com/p/44232.html

上一篇: UISearchBar键盘

下一篇: UITextField iOS:如何处理解雇键盘按钮?