在我的應用程序中,我有4個UI按鈕。單擊顯示相同警報視圖的每個按鈕包含學習和播放選項,同時單擊警報視圖,要顯示不同視圖取決於uibutton選擇。這裏是我的alert view的代碼。請幫助我在點擊選項上執行不同的視圖。用於多按鈕,多視圖的相同UIalertview
-(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;
}
}
沒有你的代碼.... – IronManGill
@Gill代碼更新 – iosdev
但這裏你有不同的警報意見...請更清楚:) – IronManGill