In my application ,i having 4 UIbuttons .On click each button showing same alert view contains learn and play option,while clicking alert view, want to show the different view depends on the uibutton selection.Here my code for alert view. please help me to perform diffrent view on click option.
-(IBAction)animals
{
UIAlertView *alert1=[[UIAlertView alloc]initWithTitle:@"" message:@"" delegate:self cancelButtonTitle:nil otherButtonTitles:@"LEARN",@"PLAY",@"CANCEL",nil];
[alert1 show];
}
-(IBAction)birds
{
UIAlertView *alert2=[[UIAlertView alloc]initWithTitle:@"" message:@"" delegate:self cancelButtonTitle:nil otherButtonTitles:@"LEARN",@"PLAY",@"CANCEL",nil];
[alert2 show];
}
-(IBAction)direct
{
UIAlertView *alert3=[[UIAlertView alloc]initWithTitle:@"" message:@"" delegate:self cancelButtonTitle:nil otherButtonTitles:@"LEARN",@"PLAY",@"CANCEL",nil];
[alert3 show];
}
-(IBAction)fruit
{
UIAlertView *alert4=[[UIAlertView alloc]initWithTitle:@"" message:@"" delegate:self cancelButtonTitle:nil otherButtonTitles:@"LEARN",@"PLAY",@"CANCEL",nil];
[alert4 show];
}
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
NSString *buttonTitle=[alertView buttonTitleAtIndex:buttonIndex];
if ([buttonTitle isEqualToString:@"LEARN"])
{
animallearn *aview=[[animallearn alloc]initWithNibName:@"animallearn" bundle:nil];
[self.navigationController pushViewController:aview animated:YES];
}
else if([buttonTitle isEqualToString:@"PLAY"])
{
birdslearn *bview=[[birdslearn alloc]initWithNibName:@"birdslearn" bundle:nil];
[self.navigationController pushViewController:bview animated:YES];
}
else
{
return;
}
}
1 Answer