Dismiss keyboard on IPAD

荒凉一梦 提交于 2019-11-27 18:07:27

问题


The ResignFirstResponder for an UITextField on the Iphone semms to not working for the Ipad. How can I dismiss my keyboard programmatically?

Thanks,


回答1:


UPDATE This answer is no longer accurate. See the correct answer.

If your UITextField is in a modal page sheet view (UIModalPresentationFormSheet), then there is (currently) no way to force the device to dismiss the keyboard this devforums post from an apple engineer.




回答2:


In iOS 4.3, Apple introduced the above mentioned method, disablesAutomaticKeyboardDismissal. It returns YES for UIModalPresentationFormSheet, preventing the keyboard from dismissing.

Overriding this method works, but if you present your view controller inside a UINavigationController, you must subclass UINavigationController and override the method there.

I've confirmed that this does indeed work on iOS 6. Just make sure to pay attention to the UINavigationController clause.




回答3:


Now we can

- (BOOL)disablesAutomaticKeyboardDismissal {
    return NO;
}


来源:https://stackoverflow.com/questions/3316700/dismiss-keyboard-on-ipad

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!