0
votes

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.

1
The error is not related to the code you posted.Andrey Gordeev

1 Answers

1
votes

The exception is thrown because you're sending a message to an instance of UIView rather than its subclass, SKView. SKView understands setIgnoresSiblingOrder:, but UIView does not.

Try out this solution: https://stackoverflow.com/a/19889592/3367343