Reputation: 1227
another probably simple iPhone obj-c question for you...
I have a couple of alerts which have buttons in them that are presented to the user in certain circumstances, both are part of one view. Now I know how to tell which button was pressed, but how do I know which alert the button pressed is related to?
Any ideas would be really handy! Cheers!
Upvotes: 1
Views: 655
Reputation: 15147
You can call UIAlertView's Delegate method explained below...and check for title or alert message like this.. here i had given you the example of title...
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex == 0 && [alertView.title isEqualToString:@"Invalid"])
{
//Your Stuff goes here
}
}
Upvotes: 0
Reputation: 6475
Set a tag to each of the alerts, and compare the tag of the alert caught at the delegate method didDismissWithButtonIndex.
Set tag as, alert.tag = 10;
and check in delegate as
if (alertView.tag == 10)
Upvotes: 2
Reputation:
Try to implement a simple delgate for your alert views.
For exemple using : alertView:clickedButtonAtIndex:
you will be able to know which alert view the button pressed is related to.
Upvotes: 0