我想从我的Sprite Kit类打开Game Center Leaderboards页面,但我一直收到此错误:
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'
这就是我尝试从我的SKScene课程中打开排行榜的方式:
- (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是呈现此精灵工具包的ViewController。
答案 0 :(得分:1)
抛出异常是因为您正在向UIView的实例而不是其子类SKView发送消息。 SKView理解setIgnoresSiblingOrder:
,但UIView不理解。