2

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?

erkanyildiz
  • 13,044
  • 6
  • 50
  • 73

3 Answers3

5

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];
  • I tried nilling it, but it sometimes shows nothing but a Leaderboards button on top alone, and sometimes shows the list properly. Anyway, that's the best we can get. So I accept your answer. Thank you. – erkanyildiz Jun 06 '12 at 09:09
0

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

Jonny
  • 15,955
  • 18
  • 111
  • 232
  • Apple docs are a little bit wrong. Default is not nil. If you do not nil category property, you get the default leaderboard. If you nil it yourself, you get the list of leaderboards on iOS 5, but default leaderboard is shown again on iOS 4. – erkanyildiz Jul 18 '12 at 09:13
0

The category property is deprecated in iOS 6 and above.

Try this:

leaderboardController.identifier = @"Your leaderboard identifier as defined on iTunes connect";
dwitvliet
  • 7,242
  • 7
  • 36
  • 62