Changing text of done button in keyboard
I know there is a question about this subject alr开发者_JAVA技巧eady 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".
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. Possible values of UIReturnKeyType
are here:
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.
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. I just want to put some more details to it. As Ben Zotto points out you NEED to set the UIReturn key. 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:
yourTextField.returnKeyType = UIReturnKeyDone; //or all the other UIReturnKeys
And yes there is also the option to set the UIReturnKey
to UITextFields
created in Storyboard
. Select the textfield in the view controller and go to the Attributes inspector
and set the Return Key
to something else than "Default":
This might be simple to most of the iOS guys. 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):
setReturnKeyType:(UIReturnKeyDefault|UIReturnKeyGo|UIReturnKeyGoogle|UIReturnKeyJoin|UIReturnKeyNext|UIReturnKeyRoute|UIReturnKeySearch|UIReturnKeySend|UIReturnKeyYahoo|UIReturnKeyDone|UIReturnKeyEmergencyCall)
精彩评论