GKLeaderboardViewController initial leaderboard

2019-07-18 02:02发布

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?

3条回答
兄弟一词,经得起流年.
2楼-- · 2019-07-18 02:18

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];
查看更多
迷人小祖宗
3楼-- · 2019-07-18 02:18

The category property is deprecated in iOS 6 and above.

Try this:

leaderboardController.identifier = @"Your leaderboard identifier as defined on iTunes connect";
查看更多
男人必须洒脱
4楼-- · 2019-07-18 02:33

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

查看更多
登录 后发表回答