How can I automatically enable the shift key?
When the user types in my text field, I want the first letter of every word to be c开发者_开发知识库apitalised. One way of doing this is use textField.autocapitalisationType
, which autocorrects every word after the user has typed it - but this method is causing separate problems for me (see my other question).
The Contacts app uses a different approach - when the user types a name, the shift key auto-highlights at the start of every word. How can I do this?
This should result in the text field capitalizing each word:
textField.autocapitalizationType = UITextAutocapitalizationTypeWords;
Alternatively, if you made the text field in Interface Builder, you could set its Capitalization
property to Words
.
From the iOS Developer Library documentation:
This property determines at what times the Shift key is automatically pressed, thereby making the typed character a capital letter. The default value for this property is UITextAutocapitalizationTypeSentences.
I believe this describes what you are looking for. The value you want is UITextAutocapitalizationTypeWords
.
精彩评论