【问题标题】:Attempt to present GameViewController on ViewController which is waiting for a delayed presention of GKTurnBasedMatchmakerViewController to complete尝试在等待 GKTurnBasedMatchmakerViewController 延迟呈现完成的 ViewController 上呈现 GameViewController
【发布时间】: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];

【问题讨论】:

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


    【解决方案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&lt;GKTurnBasedMatchmakerViewControllerDelegate, GKLocalPlayerListener&gt; { 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。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-10-20
    • 2015-04-21
    • 2016-11-29
    • 2021-11-05
    • 1970-01-01
    • 1970-01-01
    • 2017-05-24
    相关资源
    最近更新 更多