Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AutoCapitalization of TextField of UIAlertView

I’m popping up a UIAlertView with a UITextField in it. I want the text field to auto-capitalize all words. I’m doing this by setting properties of the text field, but they have no effect at runtime. Here’s my code:

UIAlertView* alert = [[UIAlertView alloc] initWithTitle: title
                                                message: message
                                              delegate: self
                                      cancelButtonTitle: @"Cancel"
                                      otherButtonTitles: @"Create", nil];
alert.alertViewStyle = UIAlertViewStylePlainTextInput;
UITextField* titleField = [alert textFieldAtIndex: 0];
titleField.autocapitalizationType = UITextAutocapitalizationTypeWords;
[alert show];

this autocapitalization is working on UITextField form XIB but this is not working on UIAlertView ,i am using iOS 6.

like image 336
kshitij godara Avatar asked Oct 22 '22 01:10

kshitij godara


1 Answers

If it doesn't change your requirements, using

titleField.autocorrectionType = UITextAutocorrectionTypeDefault;

along with

titleField.autocapitalizationType = UITextAutocapitalizationTypeWords;

gives you the desired effect.

like image 67
Naz Mir Avatar answered Oct 29 '22 23:10

Naz Mir