tags:

views:

1477

answers:

1

I want to accept password using an alert view. Following is the code I am using. But I am unable to figure out why does the keyboard pop out two times instead of once? Any ideas?

UIAlertView *passwordAlert = [[UIAlertView alloc]
   initWithTitle:@"Enter Password" message:@"" 
   delegate:self cancelButtonTitle:@"Cancel"      
   otherButtonTitles:@"Submit",nil];

[passwordAlert addTextFieldWithValue:@"" label:@"Password"];

UITextField *textfield = [passwordAlert textFieldAtIndex:0];
textfield.secureTextEntry = YES;
[passwordAlert setTag:10];
[passwordAlert show];
A: 

Not entirely sure where addTextFieldWithValue is defined but you may want to check your .xib file to make sure you didn't place double views on the "stage" as in this post:

http://www.iphonedevsdk.com/forum/iphone-sdk-development/1479-uialertview-popping-up-twice.html

Also, check out this post. Looks like you may have to "tell the text field to become first responder before showing the alert view, you'll wind up with two keyboards":

http://www.iphonedevsdk.com/forum/iphone-sdk-development/2753-new-info-adding-text-fields-alerts.html#post14701

Typeoneerror
Thanks man, that worked..! :-)
Neo
No problem. I see that that method you're using is undocumented. Pretty rad! Is there a source somewhere for these methods?
Typeoneerror
Use of private APIs in the iPhone SDK are grounds for App store rejections. Just be reminded of that.
futureelite7
Nothing in this answer or the links are private.
Typeoneerror