操作键盘

发布于 2024-10-17 16:09:21 字数 154 浏览 3 评论 0原文

因此,我想更改应用程序内键盘的布局,以便它将包含一个“下一个”按钮(它将在文本字段之间切换,类似于普通键盘上的 Tab 键)和“完成”按钮(以关闭我想改变的另一件事是,当您选择某些文本字段(仅接受数字)时,使键盘显示数字键盘而不是通常的布局。但是,我不知道如何做这样的事情。任何帮助将不胜感激。

So, I'd like to change the layout of the keyboard inside my app, such that it will include a next button(which would switch between text fields, similar to the tab key on a normal keyboard) and done button (to dismiss the keyboard altogether).Another thing I'd like to change would be to make the keyboard bring up the numpad instead of the usual layout when you choose certain text fields (which are meant to accept numbers only). However, I don't have a clue how to do such a thing. Any assistance would be greatly appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

半窗疏影 2024-10-24 16:09:21

抱歉,除了在 Apple 的不同系统键盘之间进行选择之外,如果您想要“下一步”和“完成”,则必须自己编写整个内容...

因此您可以在“完成”按钮和“下一步”按钮之间进行选择。这些只是将 Return 键重命名为 Done 或 Next;因此你不能同时进行下一步和完成。

来获取“下一步”按钮

textField.returnKeyType = UIReturnKeyNext

您可以通过设置“当您获取返回键消息时,您可以在用户的​​下一个文本字段上调用 ​​setFirstResponder” 。大概在最后一个字段中,您可以通过设置“完成”按钮

textField.returnKeyType = UIReturnKeyDone

对于数字键盘,您可以设置您的

 textField.keyboardType = UIKeyboardTypeNumberPad

键盘类型的选择是:

   UIKeyboardTypeDefault,
   UIKeyboardTypeASCIICapable,
   UIKeyboardTypeNumbersAndPunctuation,
   UIKeyboardTypeURL,
   UIKeyboardTypeNumberPad,
   UIKeyboardTypePhonePad,
   UIKeyboardTypeNamePhonePad,
   UIKeyboardTypeEmailAddress,
   UIKeyboardTypeDecimalPad

请注意,这些都是为您本地化的。

Sorry, other than choosing between Apple's different system keyboards, if you want both Next and Done, you'd have to write the whole thing yourself...

So you have a choice between the Done button and the Next button. These just rename the Return key to Done or Next; hence you can't have both Next and Done at the same time.

You get the Next button by setting

textField.returnKeyType = UIReturnKeyNext

When you get the return key msg, you can then call setFirstResponder on the next text field for your user. Presumably on the last field, you get the Done button by setting

textField.returnKeyType = UIReturnKeyDone

For the number keypad you can set your

 textField.keyboardType = UIKeyboardTypeNumberPad

Your choices for keyboard types are:

   UIKeyboardTypeDefault,
   UIKeyboardTypeASCIICapable,
   UIKeyboardTypeNumbersAndPunctuation,
   UIKeyboardTypeURL,
   UIKeyboardTypeNumberPad,
   UIKeyboardTypePhonePad,
   UIKeyboardTypeNamePhonePad,
   UIKeyboardTypeEmailAddress,
   UIKeyboardTypeDecimalPad

Note that these are all localized for you.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文