0

My app inits with a navigation controller that opens up a table view.

If I then click on the menu icon in the header a modal segue gets fired and a login screen shows up. If you then login another modal segue gets fired and you end up on the account screen.

What I now want to do is to remove all other underlying VC's and make the account VC the first VC in the navigation stack. Is that possible?

rmaddy
  • 314,917
  • 42
  • 532
  • 579
user2722667
  • 8,195
  • 14
  • 52
  • 100

1 Answers1

0

Yes it's possible with setViewControllers:animated:, you can even make the transition animatable:

ViewController *viewController = [[ViewController alloc] init];
[navigationController setViewControllers:@[viewController] animated:YES];
katleta3000
  • 2,484
  • 1
  • 18
  • 23
  • You asked if you can make your account VC first in the stack. `ViewController` in my example is your account VC. – katleta3000 Oct 27 '15 at 19:02
  • Yes but where? import UIKit class AccountViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() let viewController: UIViewController = AccountViewController() navigationController!.setViewControllers([viewController], animated: true) } } Says found nil. Can you provide a full example? – user2722667 Oct 27 '15 at 19:07
  • provide your full code in your edit, not in comment - it's unreadable – katleta3000 Oct 27 '15 at 19:29