-1
UIViewController *vc1 = [[UIViewController alloc] init];
vc1.view.backgroundColor = [UIColor redColor];
UIViewController *vc2 = [[UIViewController alloc] init];
vc2.view.backgroundColor = [UIColor blueColor];

[self.navigationController pushViewController:vc1 animated:YES];
[self.navigationController pushViewController:vc2 animated:YES];

This is my code, when i run this , i get a red ViewController rather than a blue one. So i want to know what's problem is?

  • https://stackoverflow.com/questions/21857222/how-to-push-two-view-controllers-but-animate-transition-only-for-the-second-one – Muhammad Zohaib Ehsan Mar 06 '19 at 10:24
  • This is because after push control is shifted to red viewcontroller. If you want to push to blue.. you have to do it on red viewcontroller's viewWillAppear – ketaki Damale Mar 06 '19 at 10:26

1 Answers1

0

You're pushing two controllers with animation, in which case, during the animation of the first one, you can't push the second one.

Either push the first one without the animation, or just use setViewControllers: method.

Adis
  • 4,512
  • 2
  • 33
  • 40