Calling currentModalViewController immediately after rejecting the ModalViewControllerAnimated function has problems

I have a 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 a problem that dismissal works, but not real. When I changed rejectModalViewControllerAnimated: YES to reject ModalViewControllerAnimated: NO, it worked, but it doesn’t look very good.

Any help is appreciated.

+4
source share
3 answers

@adam has the right idea, but you don’t want to wait for some kind of arbitrary delay. This is fragile because it may take some time to complete the animation. You want to wait until the previous controller is actually fired. The best place in my experience to put this in your current viewDidAppear: view controller viewDidAppear: This will be called after your modal has completely disappeared. See this question for sample code addressing a similar problem.

+5
source

Try to wait 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]; } 
0
source

Try calling:

 [menuViewController dismissModalViewControllerAnimated:NO]; 

before calling:

 [menuViewController presentModalViewController:avatarSelectionViewController animated:YES]; 
-1
source

All Articles