1

我正在我的应用程序中实现 Game Center,但在尝试读取 iOS 6 中的 leaderboardCategory 属性时遇到问题。

下面是我展示 GKGameCenterViewController 的方式:

    GKGameCenterViewController *gcViewController = [[GKGameCenterViewController alloc]init];
    [gcViewController setLeaderboardCategory:currentLeaderboard];
    [gcViewController setGameCenterDelegate:self];
    [self presentViewController:gcViewController animated:YES completion:NULL];
    [gcViewController release];

然后,当调用委托时,我检查 leaderboardCategory 属性显示的内容:

-(void)gameCenterViewControllerDidFinish:(GKGameCenterViewController *)gameCenterViewController{
    NSLog(@"%@", gameCenterViewController.leaderboardCategory);
}

麻烦的是,无论我在关闭前切换到哪个排行榜,它总是显示我通过的第一个。

根据苹果的文档:

当排行榜出现时,该属性的值决定了向玩家显示的排行榜内容。当玩家更改他们查看的排行榜内容时,leaderboardCategory 属性会自动更新。例如,为了保留玩家的选择,您可以在屏幕关闭后读取 leaderboardCategory 属性,并在下次初始化视图控制器时设置该值。

现在,我也尝试使用 GKLeaderboardViewController,但没有成功。但是,当我在 iOS 5 中使用 GKLeaderboardViewController(GKGameCenterViewController 在 iOS 6 之前不可用)时,“类别”属性按照 Apple 文档的建议进行更新。

我错过了什么?

4

0 回答 0