简体   繁体   English

编辑时在键盘上方直接显示文本字段

[英]Showing the textfield directly above keyboard when editing

I would like to try and make the text field appear above the keyboard when in editing mode, as shown in this picture, which is in the app Clash of Clans: 我想尝试使文本字段在编辑模式下出现在键盘上方,如下图所示,该图位于应用程序《部落冲突》中:

在此处输入图片说明

Is this achievable through some code or doing stuff in the Interface Builder, or have Supercell (makers of Clash of Clans) done this themselves? 这是通过某些代码或在Interface Builder中完成工作来实现的,还是由Supercell(《部落冲突》的制造商)自己完成?

You should look into the inputAccessoryView . 您应该查看inputAccessoryView

As it says here : 因为它说在这里

This property is typically used to attach an accessory view to the system-supplied keyboard that is presented for UITextField and UITextView objects. 此属性通常用于将附件视图附加到为UITextField和UITextView对象显示的系统提供的键盘上。

You add the inputAccessoryView to the individual UITextField and UITextView views you have on your page, meaning that you can have separate inputAccessoryView s for the various textfields if so desired. 您可以将inputAccessoryView添加到inputAccessoryView上的单个UITextFieldUITextView视图中,这意味着,如果需要,您可以为各个文本字段提供单独的inputAccessoryView

So in your case you would need to create your own view containing a UITextField and that checkmark button you have on the right and then add that view as a inputAccessoryView to your textfields and then it should appear right above your keyboard. 因此,在您的情况下,您需要创建自己的包含UITextField的视图以及右侧的选中标记按钮,然后将该视图作为inputAccessoryView添加到您的文本字段中,然后它应出现在键盘上方。

Hope that is enough to get you started, now you at least know that you should search for inputAccessoryView to see what can be done :) 希望这足以让您入门,现在您至少知道您应该搜索inputAccessoryView来了解可以做什么:)

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

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