Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to customize UIAlertView? Will Apple approve it?

I am using a custom UIAlertView with UITextField 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?

like image 248
Ahmad Kayyali Avatar asked Apr 19 '11 13:04

Ahmad Kayyali


4 Answers

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];
like image 161
saadnib Avatar answered Nov 06 '22 05:11

saadnib


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];
like image 43
Saurabh Avatar answered Nov 06 '22 07:11

Saurabh


Check below blog tutorial for the complete solution.

http://junecloud.com/journal/code/displaying-a-password-or-text-entry-prompt-on-the-iphone.html?cmd=success#comment3870

like image 41
Jhaliya - Praveen Sharma Avatar answered Nov 06 '22 07:11

Jhaliya - Praveen Sharma


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:

How can I customize an iOS alert view?

like image 43
sudo rm -rf Avatar answered Nov 06 '22 05:11

sudo rm -rf