Pregunta

I have three View Controller VC1,VC2 and VC3.

VC2 is of a 3rd party library and it is presented on VC1.

Then VC2 dismissed itself and send a callback to VC1 and VC1 try to present VC3 on itself but failed.

Is there some way to present VC3 immediately after dismissing VC2 ?

-(void)onDismisLoginVC{

    MessageVC *messageVC = [[MessageVC alloc] initWithNibName:@"MessageVC" bundle:nil];
    [self.navigationController presentViewController:messageVC animated:YES completion:NULL];

}

Unfortunately I can not use ^completion block of dismissing presented viewcontroller in VC2 because I am just receiving a callback to this method and can't edit code of VC2.

¿Fue útil?

Solución

I know we all always put nil for the completion block... but it actually does have some use. I assure you.

[self dismissViewControllerAnimated:YES completion:^{
    //code to be executed with the dismissal is completed
    // for example, presenting a vc or performing a segue
    }];

Otros consejos

This is the one I use to dismiss a Facebook login view controller.

UIViewController *theTrick = self.presentingViewController;
UIViewController *toPresent = [self.storyboard instantiateViewControllerWithIdentifier:@"toPresentViewController"];

[self dismissViewControllerAnimated:YES completion:^{
    [theTrick presentViewController:toPresent animated:YES completion:nil];
}];

Thanks for help guys. Adding a little bit delay before presenting VC3 solved the problem.

-(void)onDismisLoginVC{

[self performSelector:@selector(presentMessageVC) withObject:self afterDelay:1];

}

-(void)presentMessageVC
{

MessageVC *messageVC = [[MessageVC alloc] initWithNibName:@"MessageVC" bundle:nil];
[self.navigationController presentViewController:messageVC animated:YES completion:NULL];

}
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top