0

I'm working with three view contollers, the first called "menuVC" embedded in a navigation controller, and then "viewVC" and "resultsVC". I'm using push segues from VC to VC.

Now, my problem is, that every time I return to the first "menuVC" from the last "resultsVC", both viewDidLoad and viewDidAppear is envoked. As far as I can read everywhere, a navigation controller scene with push segues will never "pop" the rootviewcontroller, or any view controller for that matter, when I use push segues...? Or is there something I'm missing?

So, my question is - why is my first view controller "MenuVC" loading a new instance every time, when I should actually just be returning to the same instance of the "MenuVC"?

Suhail kalathil
  • 2,673
  • 1
  • 13
  • 12
  • How u come back to menuVC from resultVC.Ur flow is like menuVC->push->viewVC->push->resultVC , r8? – Suhail kalathil Sep 18 '14 at 10:28
  • if you push your view every time then it will load new instance everytime so try popping the view controller.Check this link http://stackoverflow.com/questions/11035809/pop-the-current-view-using-segues-storyboard-on-ios-5 – xphobia Sep 18 '14 at 10:54
  • @Suhail > Yes, exactly. And from resultVC->any of the two. – user4030788 Sep 18 '14 at 14:41
  • @xphobia > Thanks, yes. I'll try it out. But popping a view controller removes stuff, doesn't it? My problem is that I need a VC not to be removed... – user4030788 Sep 18 '14 at 14:44

1 Answers1

0
it depends on how to came back to the rootview controller from the last view controller. 
 you  should better use 

 UIViewController *vc=[nav viewControllers].lastObject;

 [vc.navigationController popToRootViewControllerAnimated:FALSE];
user2885077
  • 702
  • 6
  • 14
  • I'm moving from VC to VC with [self performSegueWithIdentifier:@"returnToVC" sender:self]. I'm not moving to "last object" - just to one of the other VC's. – user4030788 Sep 18 '14 at 14:27
  • Okay, I tried to make a class for my navigation controller, but the program totally freaked. I guess that is not something you just do. But I can see, that I need to organize my views somehow. Can you give me a simple advice about that? – user4030788 Sep 18 '14 at 18:32
  • Ok, after a couple days my concrete brain is slowly getting it... thanks for helping! I was having trouble with both my viewdidload and viewdidappear, but I think it's soon in place. – user4030788 Sep 20 '14 at 07:48