尝试在等待 GKTurnBasedMatchmakerViewController 延迟呈现完成的 ViewController 上呈现 GameViewController
Posted
技术标签:
【中文标题】尝试在等待 GKTurnBasedMatchmakerViewController 延迟呈现完成的 ViewController 上呈现 GameViewController【英文标题】:Attempt to present GameViewController on ViewController which is waiting for a delayed presention of GKTurnBasedMatchmakerViewController to complete 【发布时间】:2015-04-22 20:02:06 【问题描述】:每次运行我的应用程序时,我都会在调试日志中收到该错误。我单击查找游戏,它带我进入主屏幕,由于此错误,键盘无法工作,当我点击后退按钮时,它只是弹出视图控制器(再次由于此错误)。我不知道如何解决它,所以任何帮助将不胜感激。谢谢。
// 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】:GameKit 文档指出您的 didFindMatch 方法应该关闭视图控制器并对匹配对象执行所需的操作。
你的方法应该是这样的。
- (void)turnBasedMatchmakerViewController: (GKTurnBasedMatchmakerViewController *)viewController didFindMatch:(GKTurnBasedMatch *)match
// Dismiss the view controller
[viewController dismissViewControllerAnimated:YES completion:nil];
// Perform your logic
来自GameKit documentation:
您的游戏应该关闭视图控制器并使用匹配对象 向玩家显示比赛的当前状态。
【讨论】:
还是同样的问题。// Dismiss the view controller [viewController dismissViewControllerAnimated:YES completion:nil]; // Present next controller here [presentingViewController performSegueWithIdentifier:@"GamePlayScene" sender:match];
你的presentingViewController
是什么?
@interface GameKitHelper: NSObject<GKTurnBasedMatchmakerViewControllerDelegate, GKLocalPlayerListener> UIViewController *presentingViewController;
--- Break --- - (void)findMatchWithMinPlayers:(int)minPlayers maxPlayers:(int)maxPlayers viewController:(UIViewController *)viewController presentingViewController = viewController;"
-Break // This line of code breaks the back button on game screen [presentingViewController presentViewController:mmvc animated:YES completion:nil];
我的实际视图控制器都没有称为presentingViewController。以上是关于尝试在等待 GKTurnBasedMatchmakerViewController 延迟呈现完成的 ViewController 上呈现 GameViewController的主要内容,如果未能解决你的问题,请参考以下文章
尝试在等待 GKTurnBasedMatchmakerViewController 延迟呈现完成的 ViewController 上呈现 GameViewController
Discord.js - 尝试等待异步进程并允许递归调用包装器