我有一个游戏,当你松开时,我试图回到主屏幕。松开时,这段代码会运行,但是当我在代码末尾取消注释行时,当我尝试运行它时会出现错误。视图控制器和主屏幕和游戏的分类是不同的。我在网上找不到任何有用的东西。
-(void)resetAll {
[randomMain invalidate];
CGRect frame = [player frame];
frame.origin.x = 137.0f;
frame.origin.y = 326.0;
[player setFrame:frame];
CGRect frame2 = [enemy frame];
frame2.origin.x = 137.0f;
frame2.origin.y = 20.0;
[enemy setFrame:frame2];
[NSObject cancelPreviousPerformRequestsWithTarget:self];
[timerImageView stopAnimating];
counter.text=@"";
int sum = [lastRoundCash intValue] + [playerCash intValue];
playerCash = [NSString stringWithFormat:@"%d", sum];
[self performSelector:@selector(save) withObject:nil afterDelay:0];
[self performSelector:@selector(updateLabelState) withObject:nil afterDelay:0];
[freezeUseOutlet setHidden:true];
int x = [lastRoundRound floatValue];
int y = [highScore floatValue];
if (x>y) {
highScore=lastRoundRound;
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"New High Score!" message:[NSString stringWithFormat:@"You beat your high score! Your high score is now %@!",highScore] delegate:nil cancelButtonTitle:@"Dismiss" otherButtonTitles:nil];
[alert show];
[self performSelector:@selector(updateLabelState) withObject:nil afterDelay:0];
[self.navigationController pushViewController:ViewController animated:YES];
}
}
答案 0 :(得分:0)
我想你想要弹出视图控制器。