phpN00b
phpN00b

Reputation: 138

How Can I Display All Available Game Center Leaderboards, Rather Than Automatically Showing The Default Leaderboard?

To load the Game Center leaderboard, I currently call:

-(void) showLeaderboard:(NSString*)leaderboardId
{
    GKLeaderboardViewController *viewController = [GKLeaderboardViewController new];
    viewController.leaderboardDelegate = self;
    if (leaderboardId)
    {
        viewController.category = leaderboardId;
    }

    [[self topViewController] presentViewController:viewController animated:YES completion:nil];
}

However this always loads up the default leaderboard, and then the user much press the back button to view all the available leaderboards.

Since my method is called from the main menu of my game, this isn't really appropriate to take my player to level 1's leaderboard.

How can I load up the view controller to already just be displaying all the available leaderboards, rather than make my player hit the back button...

Desired Result... Desired Result...

What happens... enter image description here

Upvotes: 4

Views: 1084

Answers (1)

Andrew
Andrew

Reputation: 15377

Instead of GKLeaderboardViewController, you are looking for GKGameCenterViewController.

GKGameCenterViewController *viewController = [GKGameCenterViewController new];
viewController.viewState = GKGameCenterViewControllerStateLeaderboards;

You may want to load either GKGameCenterViewController or GKLeaderboardViewController depending on weather leaderboardId is set or not.

If that doesn't work, you should try this workaround.

Upvotes: 6

Related Questions