我有代码
- (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:YES to dismissModalViewControllerAnimated:NO它工作但看起来不太好。
感谢任何帮助。
答案 0 :(得分:5)
@adam有正确的想法,但你不想等待一些任意的延迟。这很脆弱,因为动画可能需要花费任何时间才能完成。您希望等待前一个视图控制器实际完成解雇。根据我的经验,最好的位置是你当前的视图控制器viewDidAppear:
。这将在你的模态完全消失后调用。有关解决类似问题的示例代码,请参阅this question。
答案 1 :(得分:0)
试着等一下......
- (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];
}
答案 2 :(得分:-1)
尝试致电:
[menuViewController dismissModalViewControllerAnimated:NO];
致电之前:
[menuViewController presentModalViewController:avatarSelectionViewController
animated:YES];