How to customize UIAlertView? Will Apple approve it?
Solution 1
You can add a textfield to your UIAlertView
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"title" message:@"msg" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:nil];
UITextField *txtField = [[UITextField alloc] initWithFrame:CGRectMake(12.0, 45.0, 260.0, 25.0)];
[alertView addSubview:txtField];
[alertView show];
[alertView release];
Solution 2
See my blog post of doing this and its perfectly accepted code by apple. I added this in some of my apps and they all got accepted. So use it without fear!!
Here is the code you can use :
UIAlertView *myAlertView = [[UIAlertView alloc] initWithTitle:@"Your title here!" message:@"this gets covered" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK", nil];
UITextField *myTextField = [[UITextField alloc] initWithFrame:CGRectMake(12.0, 45.0, 260.0, 25.0)];
[myTextField setBackgroundColor:[UIColor whiteColor]];
[myAlertView addSubview:myTextField];
CGAffineTransform myTransform = CGAffineTransformMakeTranslation(0.0, 130.0);
[myAlertView setTransform:myTransform];
[myAlertView show];
[myAlertView release];
Solution 3
Check below blog tutorial for the complete solution.
Solution 4
iOS 5 now supports this natively. Check out UIAlertView's alertViewStyle
property.
Solution 5
If you're concerned about rejection, you can always roll your own view that has animations similar to a UIAlertView
. Check this question out here:
Ahmad Kayyali
Software Engineer @ Samsung, sometimes musician & guitar teacher
Updated on June 15, 2022Comments
-
Ahmad Kayyali about 2 years
I am using a custom
UIAlertView
withUITextField
to get password from the user.I have been told that this custom view may cause my App to get reject by Apple; is that correct? If so, what is the appropriate replacement for my custom control?
-
Ahmad Kayyali about 13 yearsThank you very much for the post, i am having ZERO problems doing that, my concerns are is that against apple policy for posting iPhone Application.
-
Ahmad Kayyali over 12 yearsthank you, I am aware of this new feature, I already switched to it.