GKLeaderboardViewController initial leaderboard

浪子不回头ぞ 提交于 2020-01-15 04:57:39

问题


When GKLeaderboardViewController is presented, it shows first leaderboard on the list, even if the GKLeaderboardViewController's leaderboard category is not set. Only way to see the list of all leaderboards is clicking Leaderboards button at the top.

Is there any way to display list of all leaderboards when GKLeaderboardViewController is presented?


回答1:


You can set category to nil.

    GKLeaderboardViewController *leaderboardController = [[GKLeaderboardViewController alloc] init];
    if (leaderboardController != NULL)
    {
        //leaderboardController.category = kLeaderboardID;
        leaderboardController.category = nil;
        leaderboardController.timeScope = GKLeaderboardTimeScopeWeek;
        leaderboardController.leaderboardDelegate = self;
        [self presentModalViewController: leaderboardController animated: YES];
    }
    [leaderboardController release];



回答2:


Apple docs:

The category property must either be nil or it must match a category identifier you defined when you created your leaderboards on iTunes Connect. If nil, the view displays scores for the aggregate leaderboard. Default is nil.

http://developer.apple.com/library/ios/documentation/GameKit/Reference/GKLeaderboardViewController_Ref/Reference/Reference.html#//apple_ref/occ/instp/GKLeaderboardViewController/category




回答3:


The category property is deprecated in iOS 6 and above.

Try this:

leaderboardController.identifier = @"Your leaderboard identifier as defined on iTunes connect";


来源:https://stackoverflow.com/questions/10900430/gkleaderboardviewcontroller-initial-leaderboard

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!