有没有办法在新的UIAlertView
上设置文字输入的自动大写选项?
我想以大写字母开头:
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Add Name" message:@"Enter name for routine" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Add", nil];
[alert setAlertViewStyle:UIAlertViewStylePlainTextInput];
[alert show];
答案 0 :(得分:40)
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Add Name" message:@"Enter name for routine" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Add", nil];
[alert setAlertViewStyle:UIAlertViewStylePlainTextInput];
[alert textFieldAtIndex:0].autocapitalizationType = UITextAutocapitalizationTypeSentences;
[alert show];
答案 1 :(得分:2)
根据您的喜好有三种类型。
首先是将每个单词的第一个字母大写:
[alert textFieldAtIndex:0].autocapitalizationType = UITextAutocapitalizationTypeWords;
第二个是大写所有单词
[alert textFieldAtIndex:0].autocapitalizationType = UITextAutocapitalizationTypeAllCharacters;
第三是将句子中的每个单词都大写
[alert textFieldAtIndex:0].autocapitalizationType = UITextAutocapitalizationTypeSentences;