UITextField keyboard doesn't appear

旧巷老猫 提交于 2019-12-10 04:12:07

问题


I have a very simple screen with an UITextField with the default configuration, nothing special.

When I touch the UITextField, the keyboard doesn't pops up.

I haven't any custom control, behavior or anything else, just that, but it doesnt'work.

I've done this in previous apps iPhone/iPad apps already on the AppStore but i can't figure out what's going wrong here.

The UITextField is created in Interface Builder, in the nib file.
I've been doing some research and i added an IBAction in the UIViewController for UItextField TouchDown event and the IBOutlet for the UITexField.
In the first line of the code i added:

[textFild becomeFirstResponder];

That's the default behavior of the UITextField, when you touch it, it becomes the first responder asking the system to show the keyboard.
I debugged it and it runs that line, but the keyboard still doesn't shows up.
Thanks in advance.


回答1:


One thing you should check is to make sure the containing view (the UIView that contains all the controls), which is the View icon in Interface Builder nib viewer, has User Interaction Enabled checked. If the parent container doesn't have this checked, even if the individual controls do, you will see this behavior.




回答2:


Many times your code is right, it's just the settings of your Xcode or the Simulator.

Try Toggling Keyboard Software in the Simulator

Simulator --> Hardware --> Keyboard --> Toggle Software Keyboard

OR just simply hit Command + K it would do the same thing




回答3:


I already figured out by myself! I had tha UITextField in a UIViewController that gets presented from another view controller who responds to motion events, and that previous View Controller was allways the First Responder. All I had to do was everytime i leave the controller's view in viewWillDisappear:(BOOL)animated, i called [self resignFirstResponder]; and that was all.




回答4:


I took me a while to find this silly oversight, but make sure that both properties of UITextView: selectable and editable are set to true.



来源:https://stackoverflow.com/questions/3589707/uitextfield-keyboard-doesnt-appear

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