尝试在ViewController上呈现GameViewController,它正在等待GKTurnBasedMatchmakerViewController的延迟呈现完成

时间:2015-04-22 20:02:07

标签: ios objective-c xcode game-center modalviewcontroller

每次运行我的应用程序时,我都会在调试日志中收到错误。我单击查找游戏,它将我带到主屏幕,由于此错误键盘不起作用,当我点击后退按钮时,视图控制器它只是弹回(再次由于此错误)。我无法弄清楚如何解决它,所以任何帮助将不胜感激。感谢。

// A peer-to-peer match has been found, the game should start
- (void)turnBasedMatchmakerViewController: (GKTurnBasedMatchmakerViewController *)viewController didFindMatch:(GKTurnBasedMatch *)match
{

// Display default view  [presentingViewController dismissViewControllerAnimated:YES completion:nil];

[presentingViewController dismissViewControllerAnimated:YES completion:^{
    // Present next controller here
[presentingViewController performSegueWithIdentifier:@"GamePlayScene" sender:match];
}];

// Removing line below fixes  Warning: Attempt to dismiss from view controller <GameNavigationController: 0x78f4f820> while a presentation or dismiss is in progress!

// [self dismissModalViewController];

1 个答案:

答案 0 :(得分:0)

GameKit文档指出你的didFindMatch方法应该关闭视图控制器并对匹配对象执行所需的操作。

你的方法应该是这样的。

- (void)turnBasedMatchmakerViewController: (GKTurnBasedMatchmakerViewController *)viewController didFindMatch:(GKTurnBasedMatch *)match {
    // Dismiss the view controller
    [viewController dismissViewControllerAnimated:YES completion:nil];
    // Perform your logic
}

来自GameKit documentation

  

您的游戏应该关闭视图控制器并使用匹配对象   向玩家显示比赛的当前状态。