为了测试和编写代码,我需要重启我的GameViewContrller
GameViewController *controller = [[GameViewController alloc] initWithNibName:@"GameViewController" bundle:nil];
[self presentModalViewController:controller animated:NO];
此方法重新启动viewController,但由于我的操作/进程正在进行,所有内存都存储在内存中,因为应用程序内存随着每次重启而增加。 我认为这不是正确的方法,并且想知道如何使用内存完全覆盖viewController,删除所有进程并重新开始。
更新
- (IBAction)restartButtonPress {
// GameViewController *controller = [[GameViewController alloc] initWithNibName:@"GameViewController" bundle:nil];
// [self presentModalViewController:controller animated:NO];
[self.view setNeedsDisplay];
}
答案 0 :(得分:2)
调用用于重新加载的[self.view setNeedsDisplay];
您查看。您可以使用[self viewDidLoad]
方法,但这对我们不利,我们也不会手动调用viewDidLoad。所以你可以使用setNeedsDisplay
。
答案 1 :(得分:0)
这只会开始一个新的。它不会重置旧的。
要删除旧版本,您需要将[controller release]
调用旧版本。