开发者

Auto-capitalise keyboard upon UITextField becoming first responder

开发者 https://www.devze.com 2023-03-29 19:17 出处:网络
When a UTextField becomes first 开发者_Python百科responder is there a way to instruct the keyboard to use the auto-capitalise mode?

When a UTextField becomes first 开发者_Python百科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.


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;
0

精彩评论

暂无评论...
验证码 换一张
取 消