Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pop view controller after dismiss

I have a navigation controller A on which i push the view controller B. From B i present modally the view controller C. I need to dismiss C and pop B at the same time. I would like to that in sequence, keeping the dismiss animation first and then the pop animation from B to A. I tried without success this code:

[self dismissViewControllerAnimated:YES completion:^{
       [self.presentingViewController.navigationController popViewControllerAnimated:YES];
}];

Any suggestion on how can i achieve this?

like image 649
Diego Avatar asked Dec 10 '25 00:12

Diego


1 Answers

If you are writing in C viewcontoller then :

UIViewController *pvc = self.presentingViewController;
UINavigationController *navController = [pvc isKindOfClass:[UINavigationController class]] ? (UINavigationController *)pvc : pvc.navigationController;
[self dismissViewControllerAnimated:YES completion:^{
  [navController popViewControllerAnimated:YES];
}];

or if in B view controller

[self.presentedViewController dismissViewControllerAnimated:YES completion:^{
   [self.navigationController popViewControllerAnimated:YES];
}];
like image 51
Parag Shinde Avatar answered Dec 12 '25 13:12

Parag Shinde



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!