在我的应用程序中,我有 4 个 UI 按钮。单击显示相同警报视图的每个按钮包含学习和播放选项,在单击警报视图时,想要显示不同的视图取决于 uibutton 选择。这是我的警报视图代码。请帮我在点击选项上执行不同的视图。
-(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;
}
}