在dismissModalViewControllerAnimated之后调用presentModalViewController有问题

use*_*805 4 iphone objective-c modalviewcontroller ios

我有代码

- (void)matchmakerViewController:(GKMatchmakerViewController *)viewController didFindMatch:(GKMatch *)match
{
    [menuViewController dismissModalViewControllerAnimated:YES];
    [GameKitWrapper getSingleton].match = match;
    match.delegate = [GameKitWrapper getSingleton].remotePlayer;
    [menuViewController presentModalViewController:avatarSelectionViewController
                                      animated:YES];
}
Run Code Online (Sandbox Code Playgroud)

但我有一个问题,即解雇是有效但不是现在.当我改变dismissModalViewControllerAnimated时:YES to dismissModalViewControllerAnimated:NO它工作但看起来不太好.

任何帮助表示赞赏.

Rob*_*ier 5

@adam有正确的想法,但你不想等待一些任意的延迟.这很脆弱,因为动画可能需要花费任何时间才能完成.您希望等待前一个视图控制器实际完成解雇.我的体验中最好的地方是你当前的视图控制器viewDidAppear:.这将在你的模态完全消失后调用.有关解决类似问题的示例代码,请参阅问题.