Far far ago, under iOS7
, U can't control what's happening inside the GKGameCenterViewController
, just this 3 options:
typedef NS_ENUM(NSInteger, GKGameCenterViewControllerState) {
GKGameCenterViewControllerStateDefault = -1,
GKGameCenterViewControllerStateLeaderboards,
GKGameCenterViewControllerStateAchievements,
GKGameCenterViewControllerStateChallenges,
};
U can set this property:
@property (nonatomic, assign) GKGameCenterViewControllerState viewState;
Like this (an example):
- (void)presentLeaderboardsOnViewController:(UIViewController *)viewController {
GKGameCenterViewController *leaderboardViewController = [[GKGameCenterViewController alloc] init];
leaderboardViewController.viewState = GKGameCenterViewControllerStateLeaderboards;
leaderboardViewController.gameCenterDelegate = self;
[viewController presentViewController:leaderboardViewController animated:YES completion:nil];
}
From iOS7
and above u have this property (never try it):
@property (nonatomic, retain) NSString *leaderboardIdentifier __OSX_AVAILABLE_STARTING( __MAC_NA, __IPHONE_7_0); // Showing specified leaderboard
So just set this property, and there u go, u have opened the GKGameCenterViewController
with your wanted Leaderboard :)
Good luck!
Edit:
To dismiss the Game Center screen, in your GKGameCenterControllerDelegate
add this method:
- (void)gameCenterViewControllerDidFinish:(GKGameCenterViewController *)gameCenterViewController {
[gameCenterViewController dismissViewControllerAnimated:YES completion:^{
}];
}