Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add multiple UITextFields to a UIAlertView in iOS 7?

Tags:

ios

iphone

I need to add Multiple UITextField on a UIAlertView in iOS 7?

 myAlertView = [[UIAlertView alloc] initWithTitle:@"Enter Your Detail" message:@"\n\n\n\n\n" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Register",nil];
txtEmail = [[UITextField alloc] initWithFrame:CGRectMake(30, 40, 220, 25)];
txtEmail.placeholder = @"email address";
txtFirstName = [[UITextField alloc] initWithFrame:CGRectMake(30, 70, 220, 25)];
txtFirstName.placeholder = @"first Name";
txtSurname = [[UITextField alloc] initWithFrame:CGRectMake(30, 100, 220, 25)];
txtSurname.placeholder = @"surname";
[myAlertView addSubview:txtEmail];
[myAlertView addSubview:txtFirstName];
[myAlertView addSubview:txtSurname];

[myAlertView show];

in IOS 6 no problem but in IOS 7 it not show UITextField

like image 437
Luna Avatar asked Dec 22 '25 05:12

Luna


1 Answers

You can't do this any more, there is no addSubview for UIAlertView any more in iOS7.

Below are good alternative:

ios-custom-alertview

MZFormSheetController

like image 174
Tarek Hallak Avatar answered Dec 23 '25 17:12

Tarek Hallak