1

When a UTextField becomes first responder is there a way to instruct the keyboard to use the auto-capitalise mode?

I thought the Settings -> General -> Keyboard -> Auto-Capitalisation setting might be controlling this behaviour but my iOS device and the simulator both have this enabled and it does not seem to have any effect.

1 Answer 1

4

The UITextField conforms to the UITextInputTraits protocol. Through that protocol, you can set the autocapitalizationType property of the UITextField to influence the capitalization behavior.

For example, if you want all characters to be capitalized by default, try the following when you initialize your text field (like in your viewDidLoad method):

testField.autocapitalizationType = UITextAutocapitalizationTypeAllCharacters;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.