Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to push two view controllers but animate transition only for the second one?

I have three controllers (FirstVC, SecondVC, ThirdVC) inside storyboad, and navigation is sequential: a user can navigate from FirstVC to SecondVC, and then to ThirdVC. Now, I need to make some button that will open ThirdVC from FirstVC but will also put SecondVC on navigation stack, so when a user will press back from ThirdVC he will be returned to SecondVC. So, I don’t need animation from FirstVC to SecondVC, just need to push SecondVC on navigation controller stack and then animate only transition to ThirdVC.

I was unable to find how disable animation for performSegueWithIdentifier, so I’m thinking I should instantiate SecondVC from storyboard manually, put it on navigation stack, and then perform performSegueWithIdentifier for ThirdVC. Any ideas how to do that?

like image 560
Centurion Avatar asked Feb 18 '14 14:02

Centurion


1 Answers

The solution you're looking for if you're in the firstVC:

NSMutableArray *controllers = [self.navigationController.viewControllers mutableCopy]; [controllers addObject:secondVc]; [controllers addObject:thirdVC]; [self.navigationController setViewControllers:controllers animated:YES]; 

This will animate in the thirdVC without the secondVc becoming visible in the process. When the user press the back button, they will return to the secondVc

like image 156
KimHafr Avatar answered Oct 05 '22 14:10

KimHafr