0

我无法显示排行榜。我认为我做对了,但我在日志中收到了这个错误

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];
}
4

2 回答 2

1
[tempVC presentModalViewController: leaderboardController animated: NO]; 

[tempVC dismissModalViewControllerAnimated:YES]; 

这应该有效。

于 2012-07-17T21:06:42.563 回答
0

不要将视图添加到 CCDirector 的 openglview

我假设您的 AppDelegate 中有此代码...如果是这样,请执行以下操作:

[window.rootViewControler.view addSubview:tempVC.view];

代替

[[[CCDirector sharedDirector] openGLView] addSubview:tempVC.view];

也..在此之前移动此代码presentModalViewController

于 2012-07-17T22:26:29.000 回答