问题
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?
回答1:
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];
回答2:
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
回答3:
The category property is deprecated in iOS 6 and above.
Try this:
leaderboardController.identifier = @"Your leaderboard identifier as defined on iTunes connect";
来源:https://stackoverflow.com/questions/10900430/gkleaderboardviewcontroller-initial-leaderboard