我的UITextField中的字符自动大写有问题。它在默认的UIKeyboard上工作得很好,但是如果我尝试使用UIKeyboardTypeNamePhonePad,那么自动大写的dosnt就可以了。
继承我的代码,
- (void)viewDidLoad {
//..
//get keyboard and textfield ready
codeTextField = [[UITextField alloc] initWithFrame:CGRectMake(20.0, 15.0, 300.0, 45.0)];
codeTextField.delegate = self;
UIFont *textFieldFont = [UIFont fontWithName:@"Helvetica" size:20.0];
[codeTextField setFont:textFieldFont];
codeTextField.textColor = [UIColor blackColor];
[codeTextField setKeyboardType:UIKeyboardTypeNamePhonePad];
[codeTextField setAutocapitalizationType:UITextAutocapitalizationTypeAllCharacters];
[codeTextField setAutocorrectionType:UITextAutocorrectionTypeNo];
//..
答案 0 :(得分:2)
如果您查看autocapitalization属性的UITextInputTraits协议参考,它会声明:
某些键盘类型不支持自动大写。具体而言,如果keyboardType属性中的值设置为UIKeyboardTypeNumberPad,UIKeyboardTypePhonePad或UIKeyboardTypeNamePhonePad,则忽略此选项。