我想點擊主菜單在遊戲結束UIAlert改變故事板壓
嘗試後切換到主菜單這樣的:
-(void)gameOver
{
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"Time's up!"
message:[NSString stringWithFormat:@"You've scored: %i points!", scoreCounter]
delegate:self
cancelButtonTitle:nil
otherButtonTitles:@"Submit to Leaderboards",@"Play Again",@"Main Menu", nil];
[alert show];
}
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
if (buttonIndex == 1) {
[self toMain];
}
if (buttonIndex == 2) {
[self toMain];
}
if (buttonIndex == 3)
{
[self toMain];
}
}
-(void)toMain
{
mainMenu *main = [[mainMenu alloc] initWithNibName:nil bundle:nil];
[self presentViewController:main animated:YES completion:NULL];
}
做什麼都沒有......
編輯
固定按鈕索引,現在面臨黑屏後[self toMain]
你已經在你的'* .h'文件添加' Protocol'? –
Stone
明確聲明協議不應該影響任何內容,但這是一個好主意。 – powerj1984