I have the code
- (void)matchmakerViewController:(GKMatchmakerViewController *)viewController didFindMatch:(GKMatch *)match
{
[menuViewController dismissModalViewControllerAnimated:YES];
[GameKitWrapper getSingleton].match = match;
match.delegate = [GameKitWrapper getSingleton].remotePlayer;
[menuViewController presentModalViewController:avatarSelectionViewController
animated:YES];
}
But I have the problem that the dismiss is working but not the present. Whe开发者_开发百科n I changed dismissModalViewControllerAnimated:YES to dismissModalViewControllerAnimated:NO it worked but does not look nice.
Any help is appreciated.
@adam has the right idea, but you don't want to wait for some arbitrary delay. That's fragile because it might take any amount of time for the animation to complete. You want to wait for the previous view controller to actually finish dismissing. The best place in my experience to put this is in your current view controller's viewDidAppear:
. That will be called after your modal has completely gone away. See this question for some example code addressing a similar problem.
Try waiting for a second....
- (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];
}
Try calling:
[menuViewController dismissModalViewControllerAnimated:NO];
before calling:
[menuViewController presentModalViewController:avatarSelectionViewController
animated:YES];
精彩评论