我想在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]
之后面临黑屏