I wanna know how can I make 2 UIAlertView, with 3 buttons, the UIAlertViews(2) needs be different, the options and the actions... how ???
2 UIAlertView with 3 buttons?
3.4k views Asked by Rafael At
3
There are 3 answers
0
On
UIAlertview delegates are deprecated in ios 9.0
Also when you add more then 2 buttons, they will be vertically assigned by IOS.
you can do with simply UIAlertController
UIAlertController * alert= [UIAlertController
alertControllerWithTitle:[[[NSBundle mainBundle] infoDictionary]
objectForKey:@"CFBundleDisplayName"]
message:@"share via"
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* fbButton = [UIAlertAction
actionWithTitle:@"Facebook"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action)
{
// Add your code
}];
UIAlertAction* twitterButton = [UIAlertAction
actionWithTitle:@"Twitter"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action)
{
// Add your code
}];
UIAlertAction* watsappButton = [UIAlertAction
actionWithTitle:@"Whatsapp"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action)
{
// Add your code
}];
UIAlertAction* emailButton = [UIAlertAction
actionWithTitle:@"Email"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action)
{
// Add your code
}];
UIAlertAction* cancelButton = [UIAlertAction
actionWithTitle:@"Cancel"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action)
{
//Handel no, thanks button
}];
[alert addAction:fbButton];
[alert addAction:twitterButton];
[alert addAction:watsappButton];
[alert addAction:emailButton];
[alert addAction:cancelButton];
[self presentViewController:alert animated:YES completion:nil];
Try this:
then do the same for the next alertView, just change the tag to 2
Then just run this method
Also - make sure you include the
UIAlertViewDelegate