Stop automatic dismissal of keyboard on iOS/disablesAutomaticKeyboardDismissal not called

青春壹個敷衍的年華 提交于 2020-01-23 11:58:58

问题


I would like to be able to have another control become the first responder yet keep the keyboard showing to the user.

I found disablesAutomaticKeyboardDismissal in UIViewController and overrode it but it never get's called (iOS 5.0)

Is there a reason this method would not get called? Is there another way to keep the keyboard showing even though it's not required by the first responder?


回答1:


Though it felt a bit like a hack what I did was make override canBecomeFirstResponder on UIView to return YES and then implement the UIKeyProtocol

https://developer.apple.com/library/IOS/documentation/UIKit/Reference/UIKeyInput_Protocol/Reference/Reference.html

But did nothing on key press. This way the keyboard stays open but the keys don't matter.



来源:https://stackoverflow.com/questions/18411562/stop-automatic-dismissal-of-keyboard-on-ios-disablesautomatickeyboarddismissal-n

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