简体   繁体   English

更改键盘中完成按钮的文本

[英]Changing text of done button in keyboard

I know there is a question about this subject already but I think it's possible to change the text of the done button of a keyboard, because many of the apps I use are in french and the text of the done button is "accéder". 我知道有关于这个主题的问题,但我认为可以更改键盘的完成按钮的文本,因为我使用的许多应用程序都是法语,完成按钮的文本是“accéder”。

But I don't know how to do this? 但我不知道怎么做?

You can't set it to arbitrary text, but you can make it a canned word by setting the returnKeyType on whatever text field or view is being used for editing. 您不能将其设置为任意文本,但可以通过在任何文本字段或视图用于编辑时设置returnKeyType来使其成为固定字。 Possible values of UIReturnKeyType are here: UIReturnKeyType可能值UIReturnKeyType

http://developer.apple.com/library/ios/#documentation/uikit/reference/UITextInputTraits_Protocol/Reference/UITextInputTraits.html%23//apple_ref/occ/intf/UITextInputTraits http://developer.apple.com/library/ios/#documentation/uikit/reference/UITextInputTraits_Protocol/Reference/UITextInputTraits.html%23//apple_ref/occ/intf/UITextInputTraits

These are generally localized with the app, though. 但是,这些通常是使用应用程序本地化的。 If your app supports an "fr" localization, and the device is set to French, you should get the localized versions of the keyboard keys. 如果您的应用支持“fr”本地化,并且设备设置为法语,您应该获得键盘键的本地化版本。

I went crazy before I found out how to ask this question right. 在我发现如何正确地提出这个问题之前,我发疯了。 First of all thanks to Ben Zotto and Emil for the answers. 首先感谢Ben Zotto和Emil的答案。 I just want to put some more details to it. 我只是想提一些细节。 As Ben Zotto points out you NEED to set the UIReturn key. 正如Ben Zotto指出你需要设置UIReturn键。 Otherwise the keypad is not going to adapt the return button to the selected language. 否则,键盘不会使返回按钮适应所选语言。 For programmatically created UITextField s just add the following to the viewDidLoad method: 对于以编程方式创建的UITextField只需将以下内容添加到viewDidLoad方法:

    yourTextField.returnKeyType = UIReturnKeyDone; //or all the other UIReturnKeys

And yes there is also the option to set the UIReturnKey to UITextFields created in Storyboard . 是的,还有一个选项可以将UIReturnKey设置为在Storyboard创建的UITextFields Select the textfield in the view controller and go to the Attributes inspector and set the Return Key to something else than "Default": 在视图控制器中选择文本字段,然后转到“ Attributes inspector并将“ Return Key ”设置为“默认”以外的其他值:

在此输入图像描述

This might be simple to most of the iOS guys. 对于大多数iOS人来说,这可能很简单。 But for beginners it is hard to find out that you need to change the default value to trigger the behavior you expect. 但对于初学者来说,很难发现您需要更改默认值以触发您期望的行为。

The language of the keyboard can't be chosen by the app, the user can set which keyboard-language to prefer, and you can't choose what it should say on the return-button. 应用程序无法选择键盘的语言,用户可以设置首选的键盘语言,并且无法在返回按钮上选择应该说的内容。

You can set the UIReturnKeyType , so that it will show something different than "return" (these will also be localized): 您可以设置UIReturnKeyType ,以便显示与“return”不同的内容(这些也将被本地化):

setReturnKeyType:(UIReturnKeyDefault|UIReturnKeyGo|UIReturnKeyGoogle|UIReturnKeyJoin|UIReturnKeyNext|UIReturnKeyRoute|UIReturnKeySearch|UIReturnKeySend|UIReturnKeyYahoo|UIReturnKeyDone|UIReturnKeyEmergencyCall)

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

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