我有一款遊戲,當您鬆動時,我試圖回到主屏幕。當你鬆動時,這段代碼會運行,但是當我在代碼的末尾取消註釋行時,它會在我嘗試運行時給我一個錯誤。視圖控制器和分類主屏幕和遊戲是不同的。我在網上找不到任何可以工作的東西。使用代碼切換視圖控制器
-(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];
[email protected]"";
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];
}
}
我在代碼中看不到註釋行。 – 2013-03-23 18:58:52