Reputation: 138
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...
What happens...
Upvotes: 4
Views: 1084
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