我在获取排行榜时遇到问题。我想我没错,但我在日志中得到了这个错误
Unbalanced calls to begin/end appearance transitions for <UIViewController: 0x105e39c0>.
这是我显示和隐藏视图的代码
- (void)showLeaderboard
{
GKLeaderboardViewController *leaderboardController = [[GKLeaderboardViewController alloc] init];
if (leaderboardController != NULL)
{ CCLOG( @" leaderboardController ok...");
tempVC = [[UIViewController alloc] init];
leaderboardController.leaderboardDelegate = self;
[[[CCDirector sharedDirector] openGLView] addSubview:tempVC.view];
leaderboardController.category = @"com.bluemesasoftware.housedefender.hightestscore";
leaderboardController.timeScope = GKLeaderboardTimeScopeAllTime;
leaderboardController.leaderboardDelegate = self;
[tempVC presentModalViewController: leaderboardController animated: YES];
}
}
- (void)leaderboardViewControllerDidFinish:(GKLeaderboardViewController *)viewController
{
[tempVC dismissModalViewControllerAnimated:YES];
[tempVC.view.superview removeFromSuperview];
[tempVC release];
}
答案 0 :(得分:1)
[tempVC presentModalViewController: leaderboardController animated: NO];
[tempVC dismissModalViewControllerAnimated:YES];
这应该有用。
答案 1 :(得分:0)
不要将视图添加到CCDirector的openglview
我假设你的AppDelegate中有这个代码...如果是这样的话:
[window.rootViewControler.view addSubview:tempVC.view];
而不是
[[[CCDirector sharedDirector] openGLView] addSubview:tempVC.view];
也..在presentModalViewController