使用presentModalViewController在xcode中切换视图时检索得分值

时间:2011-01-26 02:11:49

标签: iphone xcode presentmodalviewcontroller

我遇到了在某人完成游戏后检索游戏“高分”的问题。

我做的是:

当时间到达0时,我调用presentModalViewController方法。

GameEndingViewController *gameEndingView = [[GameEndingViewController alloc] initWithNibName:@"GameEndingViewController" bundle:nil];
gameEndingView.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self presentModalViewController:gameEndingView animated:YES];
[gameEndingView release];

我想显示我在这个gameEndingView中的主游戏循环中获得的分数。但是,似乎当我使用presentModalViewController方法切换视图时。我在游戏循环期间更新的变量得分被重置。我的整个游戏循环都在视图gameMainView中。

有人可以向我解释一下presentModalViewController的使用吗?我该如何更好地解决我的问题呢?

非常感谢。

1 个答案:

答案 0 :(得分:0)

这不是您的模态视图的问题。您在应用逻辑中遇到问题。你最好再看一遍。 好主意是将分数声明为属性并设置断点,以便您可以看到它的变化位置。