Pregunta

I am having some trouble with my auto capitalization of characters in my UITextField. It works perfectly fine on the default UIKeyboard however if I try to use UIKeyboardTypeNamePhonePad then the auto capitalization dosnt work.

heres my code,

- (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];

//..
¿Fue útil?

Solución

If you take a look at the UITextInputTraits Protocol reference for the autocapitalization property, it states that:

Some keyboard types do not support auto-capitalization. Specifically, this option is ignored if the value in the keyboardType property is set to UIKeyboardTypeNumberPad, UIKeyboardTypePhonePad, or UIKeyboardTypeNamePhonePad.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top