UITextField auto-capitalization type - iPhone App

后端 未结 7 1568
故里飘歌
故里飘歌 2021-01-30 15:29

Is there a way to set the autocapitalizationType for a UITextField so that the first letter of each word is capitalized by default?

This Is A

7条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-30 16:10

    Setting the capitalization property to "Words" will suggest that the user enter capitalized words. This can be overridden by the user by un-shifting on the keyboard. The best thing to do is capitalize the words in code:

    NSString *text = [myTextField.text capitalizedString];
    

提交回复
热议问题