0
在我的纸牌游戏游戏中,我尝试创建一个匹配项,对于某个部分来说,它可以工作;匹配成功创建游戏中心:匹配
- (void)matchmakerViewController:(GKMatchmakerViewController *)viewController didFindMatch:(GKMatch *)match {
self.match = match;
match.delegate = self;
if (!_matchStarted && match.expectedPlayerCount == 0) {
NSLog(@"Ready to start match!");
UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *vc = [sb instantiateViewControllerWithIdentifier:@"GameVC"];
vc.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[viewController presentViewController:vc animated:YES completion:nil];
//[viewController dismissViewControllerAnimated:YES completion:nil];
}
}
后,我想GKMatchmakerViewController
被解雇,我想显示的“VC” UIViewController
。在上面的例子中,这是完成的,但GKMatchmakerViewController
不会被解雇。
如果我删除了评论引号,它会在它以某种方式被解散后加载,如果我将该行放在presentViewController
行之上,则会出现一个错误消息,指出我试图在视图控制器上呈现视图控制器在视图层次结构中。
如何解除GKMVC并在“相同”时间显示“vc”?
谢谢!
感谢您的回答!我明白你在说什么,但是我的代码和平是在一个'GameKitHelper'类中。调用self是不可能的,因为它会给出一个错误,说明'presentViewController:...'在'GameKitHelper'类中不是可见的接口。要清楚:这是一个自定义的'NSObject'类,而不是'UIViewController'类。 – Niels 2014-10-01 19:01:23
@Niels啊,理解。你的AppDelegate类的名字是什么?只是AppDelegate? – Undo 2014-10-01 19:02:01
是的,它是AppDelegate – Niels 2014-10-01 20:21:35