I want to open the Game Center Leaderboards page from my Sprite Kit Class but I keep getting this error:
2014-09-13 14:24:52.183 SpriteTest[6733:77452]-[UIView setIgnoresSiblingOrder:]:
unrecognized selector sent to instance 0x7f89cf078fd0
2014-09-13 14:24:52.218 SpriteTest[6733:77452] *** Terminating app due to
uncaught exception 'NSInvalidArgumentException', reason: '-[UIView
setIgnoresSiblingOrder:]: unrecognized selector sent to instance 0x7f89cf078fd0'
This is how I'm trying to open the leaderboards from my SKScene class:
- (void)openGameCenter{
if ([GKLocalPlayer localPlayer].isAuthenticated) {
GKGameCenterViewController *leaderboardController = [[GKGameCenterViewController alloc] init];
leaderboardController.gameCenterDelegate = self;
leaderboardController.viewState = GKGameCenterViewControllerStateLeaderboards;
UIViewController *vc = [[GameViewController alloc] init];
[vc presentViewController: leaderboardController animated: YES completion:nil];
}else{
UIAlertView *alert = [[UIAlertView alloc]initWithTitle: @"Error"
message: @"You must be logged into Game Center to view the leaderboards. Open Game Center?"
delegate: self
cancelButtonTitle:@"No"
otherButtonTitles:@"Yes",nil];
[alert show];
}
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
if (buttonIndex == 1) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"gamecenter:"]];
}
}
GameViewController is the ViewController that is presenting this sprite kit.