开发者

iPhone: How to programmatically convert String entered by user into Init caps?

I have a textbox where in user enters the string.

I want 开发者_运维百科to programmatically convert this string to init caps.

How can I do that?


Try using this UITextAutocapitalizationTypeWords or UITextAutocapitalizationTypeAllCharacters

UPDATE

capitalizedString or upperCaseString will help you

[textField.text uppercaseString]; will give you all the characters in textfield as capital letters


Try

  myString = [myTextField.text capitalizedString];


Use the UITextInputTraits protocol which is confirm by both (UITextView and UITextField) input method ...

@property(nonatomic) UITextAutocapitalizationType autocapitalizationType

Try with UITextAutocapitalizationTypeAllCharacters to Capitalize all characters automatically.

myTextView.autocapitalizationType = UITextAutocapitalizationTypeAllCharacters;

Eidted: If you want to Capitalize after getting the text from you textView use below

  NSString myTextString = [myTextView.text capitalizedString];
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜