Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 在解除Modalviewcontrolleranimated后调用presentModalViewController出现问题_Iphone_Objective C_Ios_Modalviewcontroller - Fatal编程技术网

Iphone 在解除Modalviewcontrolleranimated后调用presentModalViewController出现问题

Iphone 在解除Modalviewcontrolleranimated后调用presentModalViewController出现问题,iphone,objective-c,ios,modalviewcontroller,Iphone,Objective C,Ios,Modalviewcontroller,我有密码 - (void)matchmakerViewController:(GKMatchmakerViewController *)viewController didFindMatch:(GKMatch *)match { [menuViewController dismissModalViewControllerAnimated:YES]; [GameKitWrapper getSingleton].match = match; match.delegate =

我有密码

- (void)matchmakerViewController:(GKMatchmakerViewController *)viewController didFindMatch:(GKMatch *)match
{
    [menuViewController dismissModalViewControllerAnimated:YES];
    [GameKitWrapper getSingleton].match = match;
    match.delegate = [GameKitWrapper getSingleton].remotePlayer;
    [menuViewController presentModalViewController:avatarSelectionViewController
                                      animated:YES];
}
但我有一个问题,解雇是有效的,但不是现在。当我将dismissModalViewControllerAnimated:是改为dismissModalViewControllerAnimated:不,它起作用了,但看起来不好看


感谢您的帮助。

请稍等片刻

- (void)matchmakerViewController:(GKMatchmakerViewController *)viewController didFindMatch:(GKMatch *)match
{
    [menuViewController dismissModalViewControllerAnimated:YES];
    [GameKitWrapper getSingleton].match = match;
    match.delegate = [GameKitWrapper getSingleton].remotePlayer;
    [self performSelector:@selector(presentModal) withObject:nil afterDelay:1.0];
}

- (void)presentModal {   
    [menuViewController presentModalViewController:avatarSelectionViewController
                                          animated:YES];
}

@亚当的想法是正确的,但你不想等待一些任意的延迟。这是脆弱的,因为动画可能需要任何时间才能完成。您需要等待上一个视图控制器实际完成解除。根据我的经验,最好放在当前视图控制器的
viewdide:
中。这将在你的模态完全消失后调用。有关解决类似问题的示例代码,请参阅。

尝试调用:

[menuViewController dismissModalViewControllerAnimated:NO];
致电前:

[menuViewController presentModalViewController:avatarSelectionViewController
                    animated:YES];

嗯。。在同一个runloop中关闭并显示UIView控制器可能会导致真正的UI问题,甚至崩溃(至少在我以前使用的SDK中是这样)。我经常发现,仅仅推迟下一个viewcontroller的演示并不能保证。因此,我完全避免这种设计。等待一段时间是脆弱的。如果太长,应用程序将毫无必要地没有响应;如果太短,您当前的通话将失败。我在这里找到了一个不依赖于计时的解决方案:我在这里有一个替代方案(),它不需要覆盖ViewDidDisplay:-1提问者已经尝试过了,并且反对缺少解除视图控制器的动画,不希望它消失。