Alex Rivera | Logout

UITextField will not auto capitalize throughout entire project

Asked 2009-07-14T01:32:17.917
12

For some reason, none of my UITextFields will autocapitalize. I have set the property in InterfaceBuilder as well as programatically as shown below.

cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"search_cell"];
UITextField *tf = [[UITextField alloc] initWithFrame:CGRectMake(12, 10, 320, 32)];
tf.autocapitalizationType = UITextAutocapitalizationTypeWords;
tf.returnKeyType = UIReturnKeySearch;
tf.font = [UIFont boldSystemFontOfSize:20.0];
tf.delegate = self;
[cell addSubview:tf];
[tf becomeFirstResponder];

Is there anyway I could have set some flag that disables autocapitalization throughout the whole app without realizing it?

Thanks

Edit
Report

1 Answer

0

I couldn't get it to work no matter the settings. So I just put this in the textfield's delegate:

- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {

    // Handle the backspace.
    if ([string isEqualToString:@""]) return YES;

    // Otherwise convert to uppercase and change the textfield manually.
    textField.text = [[textField.text stringByAppendingString:string] uppercaseString];
    return NO;
}
answered 2013-07-27T21:44:59.753

Your Answer