views:

58

answers:

2

My app was recently rejected due to using a private API (addTextField: method for UIAlertView, which is quite useful, might I add).

Is there any non-private alternative to UIAlertView's undocumented addTextFieldWithValue:label:?

Thanks SO much in advance!

+2  A: 

create the text field as a subview of the UIAlertView

// Ask for Username and password.
alertView = [[UIAlertView alloc] initWithTitle:_title message:@"\n \n \n" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK", nil];
// Adds a username Field
utextfield = [[UITextField alloc] initWithFrame:CGRectMake(12.0, 45.0, 260.0, 25.0)]; 
utextfield.placeholder = @"Username";
[utextfield setBackgroundColor:[UIColor whiteColor]];
utextfield.enablesReturnKeyAutomatically = YES;
[utextfield setReturnKeyType:UIReturnKeyDone];
[utextfield setDelegate:self];
[alertView addSubview:utextfield];

// Show alert on screen.
[alertView show];
[alertView release];
Aaron Saunders
Nice trick. (Small note: missed a release on the utextfield.)
No one in particular
Thanks a lot! Hopefully now I won't have to wait two weeks for someone to reject my app.
esqew
A: 

Check out this Open Source code on GitHub for adding UITextFields to a UIAlertView.

http://github.com/enormego/EGOTextFieldAlertView

Joshua