I am trying to perform the smile task of having two alerts in a single View Controller. The code below works fine, but how would I make another instance of it elsewhere in t
Step 1: Add UIAlertViewDelegate in your view controller.h file
step 2: Add the following methods in your view controller.m file
-(void)AlertMethodOne
{
UIAlertView *alertview=[[UIAlertView alloc]initWithTitle:@"AlertMethodOne" message:@"AlertMethodOne successfully Called" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:nil];
alert.tag=101;
[alertview show];
}
-(void)AletrMethodTwo
{
UIAlertView *alertview=[[UIAlertView alloc]initWithTitle:@"AletrMethodTwo" message:@"AlertMethodTwo successfully Called" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:nil];
alert.tag=102;
[alertview show];
}
call the above two methods in your viewController as like below: [self AlertMethodOne]; [self AlertMethodTwo];
Now AlertView Button Clicked Method
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if(alertView.tag==101)
{
if (buttonIndex == 0)
{
}
}
if(alertView.tag==102)
{
if (buttonIndex == 1)
{
}
}
}