Search code examples
objective-ciosgame-centerpresentmodalviewcontrollerleaderboard

GKLeaderboardViewController initial leaderboard


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?


Solution

  • 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];