2011-04-26 117 views

回答

34

使用autocapitalizationType为UITextField的大写字母。

txtfield1.autocapitalizationType = UITextAutocapitalizationTypeWords; 
+6

如果模拟器或“自动大写”从“设置”>“常规”>“键盘”>“ iOS/iDevice上的大小写 – NaXir 2013-06-13 08:14:41

+0

请注意,如果对文本字段禁用了自动更正,则此解决方案不起作用。 – alexey 2014-04-17 09:12:17

+0

如果你想使第一个字母大写,你应该使用UITextAutocapitalizationTypeSentences。因为UITextAutocapitalizationTypeWords会将文本字段中每个单词的首字母大写,而不仅仅是第一个字母。 – Werewolf 2016-04-08 08:19:22

4
txtfield1.autocapitalizationType = UITextAutocapitalizationTypeWords; 

,或者您也可以尝试

[addrecipe.txtfdName setText:[txtfield1.text capitalizedString]]; // the first character from each word in the receiver changed to its corresponding uppercase value 
14

使用此代码,以资本第一后

NSString *abc = @"this is test"; 

abc = [NSString stringWithFormat:@"%@%@",[[abc substringToIndex:1] uppercaseString],[abc substringFromIndex:1] ];  
NSLog(@"abc = %@",abc); 
8

符合要手动为每个字的第一个字母代码:

NSString* name = [addrecipe.txtfdName setText:txtfield1.text]; 
name = [name capitalizedString]; 
1

选择txtfield1和去属性检查器,有一个下拉菜单的大写字母和选择菜单形式关注

:如果您选择Word不是每个单词的第一个字符是资本

:如果句子不是每一句的第一个字的第一个字符是资本

所有字符 :所有角色都是首都

相关问题