Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone: Issue disabling Auto-Cap/autocorrect on a UITextField

For some reason, even though I disable the auto-cap and auto-correct of my UITextField, it's still capitalizing the first letter of my input.

Here is the code:

UITextField* textField = [[[UITextField alloc] initWithFrame:CGRectMake(90.0, 10.0, 213.0, 25.0)] autorelease]; [textField setClearButtonMode:UITextFieldViewModeWhileEditing]; textField.returnKeyType = UIReturnKeyGo; textField.autocorrectionType = FALSE; textField.autocapitalizationType = UITextAutocapitalizationTypeNone; textField.delegate = self; if (inputFieldType == Email) {     label.text = @"Email:";     textField.keyboardType = UIKeyboardTypeEmailAddress;     emailTextField  = textField;     textField.placeholder = @"Email Address"; } else { // password     textField.secureTextEntry = TRUE;     label.text = @"Password:";     if (inputFieldType == Password){         textField.placeholder = @"Password";         passwordTextField  = textField;     }     if (inputFieldType == ConfirmPassword){         textField.placeholder = @"Confirm Password";         confirmPasswordTextField  = textField;     }  } 

See screenshot: alt text http://grab.by/39WE

like image 807
phil swenson Avatar asked Mar 19 '10 03:03

phil swenson


People also ask

How do I turn off autocorrect in TextField?

TextField by default auto corrects values entered by users according to their locale but if you need to disable this feature then use disableAutocorrection modifier for that purpose.

How do I turn off auto capitalization in Swift?

You can turn Autocaps on and off by following the below instructions: Open your Microsoft SwiftKey app. Tap 'Typing' Check/uncheck the Auto capitalize option.


1 Answers

You're setting autocorrectionType to FALSE as if it were a BOOL, but it actually has type UITextAutocorrectionType. So FALSE is being interpreted as UITextAutocorrectionTypeDefault, which means that autocorrection is probably enabled.

I bet it found the name "Phil" in your address book and is autocorrecting the capitalization to match.

like image 67
Tom Avatar answered Oct 09 '22 04:10

Tom