3

我已经进行了设置,以便我的应用可以连接到 Game Center。我遵循指南并有一个 C++ 类包装器可以在我的其他类中调用它们。我正在使用 iPad (iOS 5.1)、iPod Touch 4th Gen (iOS 5.1) 和 iPhone 4s 和 3GS 进行测试。它可以在 iPad 设备上正常工作,但由于某些未知原因,它不能在 iPhone 和 iPod 上运行。它正确连接到沙盒,但未显示 UI,或者更确切地说,UI 位于屏幕外的某个位置。

iPhone上发生的事情是:

  1. 如果我没有登录并访问 Game Center,则会出现一个登录窗口。当我登录时,什么也没有发生。但是,控制台说添加了一个视图。
  2. 如果我已登录并访问 Game Center,则不会发生任何事情。但是,控制台说添加了一个视图。
  3. 如果我在通过身份验证之前访问 Game Center,则会出现 Game Center UI。然而...
    • Game Center 处于横向模式(那里没有问题,因为我的应用程序是横向的),但顶部栏(带有 DONE 按钮的栏)被放置为好像方向是纵向的。
    • 没有显示整个 UI,只显示了大约 30% 的屏幕。

这就是我启动 Game Center UI 的方式:

- (void)showLeaderboardForCategory:(NSString *)category
{
    // Only execute if OS supports Game Center & player is logged in
    if ( hasGameCenter )
    {
        // Create leaderboard view w/ default Game Center style
        GKLeaderboardViewController *leaderboardController = [[GKLeaderboardViewController alloc] init];

        // If view controller was successfully created...
        if (leaderboardController != nil)
        {
            // Leaderboard config
            leaderboardController.leaderboardDelegate = self;   // The leaderboard view controller will send messages to this object
            leaderboardController.category = category;  // Set category here
            leaderboardController.timeScope = GKLeaderboardTimeScopeToday;  // GKLeaderboardTimeScopeToday, GKLeaderboardTimeScopeWeek, GKLeaderboardTimeScopeAllTime

            // Create an additional UIViewController to attach the GKLeaderboardViewController to
            myViewController = [[UIViewController alloc] initWithNibName:nil bundle:nil ];

            // Add the temporary UIViewController to the main OpenGL view
            // NOTE: This is the part that I think is the suspect. I am not sure if iPhones and iPods support EAGLView.
            [ [ EAGLView sharedEGLView ] addSubview:myViewController.view ];

            // Tell UIViewController to present the leaderboard
            [ myViewController presentModalViewController:leaderboardController animated:NO ];
            NSLog( @"Leaderboard opened." );
        }
    }
}

任何帮助表示赞赏并提前感谢。

编辑:使用 OpenFeint 不是一种选择。

4

1 回答 1

2

试试这个。不要使用“EAGLView”

- (void) showLeaderboard
{
    if (!gameCenterAvailable) return;

    GKLeaderboardViewController *leaderboardController = [[GKLeaderboardViewController alloc] init];
    if (leaderboardController != nil) {
        leaderboardController.leaderboardDelegate = self;

        UIWindow *window = [[UIApplication sharedApplication] keyWindow];
        currentModalViewController = [[UIViewController alloc] init];
        [window addSubview:currentModalViewController.view];
        [currentModalViewController presentModalViewController:leaderboardController animated:YES];
    }

}
于 2012-09-25T02:11:57.273 回答