简体   繁体   English

在键盘上方显示UITextField

[英]Show UITextField above Keyboard

I am using the following tutorial to show the uitextfield above the keyboard at all times: http://mobile.tutsplus.com/tutorials/iphone/ios-sdk-keeping-content-from-underneath-the-keyboard/ 我正在使用以下教程始终显示键盘上方的uitextfield: http : //mobile.tutsplus.com/tutorials/iphone/ios-sdk-keeping-content-from-underneath-the-keyboard/

But the problem is the uitextfield only gets shown above the keyboard if the person starts typing into the field, but not if the cursor is in the textfield. 但是问题是,只有当用户开始在该字段中键入时,uitextfield才会显示在键盘上方,而如果光标在该文本字段中则不会显示。

How can I change it so that the uitextfield gets shown above the keyboard once the cursor is in the UITextField? 我如何更改它,以便一旦光标位于UITextField中,uitextfield就会显示在键盘上方?

Thanks 谢谢

Check UITextFieldDelegate and select appropriate method. 检查UITextFieldDelegate并选择适当的方法。

In this tutorial they use textFieldDidBeginEditing method to assign active textfield. 在本教程中,他们使用textFieldDidBeginEditing方法分配活动文本字段。 As it clear from method name, it executes when someone start typing in text field. 从方法名称可以清楚地看出,当有人开始在文本字段中键入内容时,它将执行。

I downloaded the sample code and work just fine for me. 我下载了示例代码,对我来说一切正常。 The only thing that I figured you could misunderstood is in the case the keyboard it's already below the textField, in these cases the view will not scroll. 我认为您可能会误解的唯一一件事是键盘已经在textField下方,在这种情况下,视图将不会滚动。

I hope this helps. 我希望这有帮助。 If it's not this that you want, please tell me more about it. 如果不是您想要的,请告诉我更多有关它的信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM