iPhone SDK NumberPad 自定义 inputView 完成按钮
目前我有一个文本字段,它可以拉出数字键盘进行输入。
我想要 NumberPad 键盘布局,但我需要一个按钮来退出该响应者。
有没有办法对 UITextField 进行编码,使其具有 NumberPad 键盘,并且键盘左侧的空白空间被“完成”、“发送”或“执行”按钮替换。
或者我需要为 UITextField 创建自定义 inputView 吗?
我本以为,既然数字键盘上有一个空白键,苹果就会让它变得有用。
Currently I have a textfield, which pulls up a NumberPad keyboard for input.
I want the NumberPad keyboard layout, but I need a button to resign that responder.
Is there a way to code the UITextField so that it has a NumberPad keyboard and the space on the left of the keyboard which is blank is replaced with a 'Done', 'Send' or 'Go' button.
Or do I need to create a custom inputView for the UITextField?
I would have thought since there is a blank key on the NumberPad apple would have made it useful for something.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
只需尝试将带有完成按钮的
UIToolBar
作为文本字段的inputAccessoryView
即可。在按钮单击事件中提供关闭键盘的代码。认为这应该适合你。或者,如果您想在键盘上绘制自定义按钮,您可以在此处搜索以获取解决方案
Just try having a
UIToolBar
with a done button on it as theinputAccessoryView
of the text field. In the button click event provide the code to dismiss the keyboard. Think that should suit you.Or if you want to have a custom button drawn over the keyboard you can search here to get the solution
如果您使用phonePad,则需要空按钮。但是您可以添加带有“应用”和“取消”按钮的
inputAccessoryView
,然后关闭数字键盘。The empty button is needed if you use phonePad. But you can add
inputAccessoryView
with 'Apply' and 'Cancel' buttons, and dismiss the number pad with then.您现在需要创建一个自定义输入视图并将其分配给文本字段的输入视图属性。我目前正在研究它,但这是正确的、经过认可的方法。不过,仅仅改变一个按钮似乎有点过分了。
You need to do a custom inputview now and assign it to the inputview property of your text field. I am currently researching it, but that is the right, approved way of doing it. It seems overkill just for changing a single button though.