Reputation: 1286
I have to show multiple UIAlerts in one viewController before iOS8 we can use the UIAlerts with tags and we can identify in clickedButtonAtIndex using tags like.
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if(alertView.tag == 1)
{
//UIAlert1 button clicked
}
if(alertView.tag == 2)
{
//UIAlert2 button clicked
}
}
so we can do stuff. how to identify button clicks of different UIAlertControllers. Because one alert1 button click i have to change the some text color and alert2 button click i have to pop the view controller.
Upvotes: 0
Views: 424
Reputation: 285059
UIAlertController
is block-based.
Create an UIAlertAction
instance for each action and pass the block to be executed after the button is tapped.
For further information read the UIAlertController "review" of Mattt Thompson.
Upvotes: 1
Reputation: 2999
You can do the following way.
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if(alertView.tag == 1)
{
//UIAlert1 button clicked
if(buttonIndex==0){//say, **Cancel** button tag
//alert2 "Cancel" button has tapped
}else if(buttonIndex==1){say, **OK** button tag
//alert2 "OK" button has tapped
}
}
if(alertView.tag == 2)
{
//UIAlert2 button clicked
if(buttonIndex==0){//say, **Yes** button tag
//alert2 "YES" button has tapped
}
}
}
Upvotes: 0