PoptorootViewController fails then removes all Viewcontrollers

Posted by Spyker on Stack Overflow See other posts from Stack Overflow or by Spyker
Published on 2010-04-02T10:15:34Z Indexed on 2010/04/02 10:23 UTC
Read the original article Hit count: 420

Filed under:
|

Trying to fix a very strange error, i have 3 view controllers that start from the app delegate and push each other accordingly. The 3rd view controller then has a toolbar button that calls the code here:

-(void)showEventBrowser;
{ 
 accelManeger.delegate = nil;
 NSLog(@"%u",[self.navigationController.viewControllers count]);
 [self.navigationController popToRootViewControllerAnimated:NO];
}

This works the first time round but when i come back to this view controller and try again. Firstly it reports that there are 3 view controllers on the stack. It then deallocs the 2nd view controller in the stack and doesnt crash but will not go any further. If i hit the button again it says there are no view controllers on the stack and fails to respond.

I have logs for all the viewdid, viewwill, e.t.c in each view controller and there appears to be no odd behaviour. Also no memory warnings from any view controllers.

Why would this work once through but not the second time ?

© Stack Overflow or respective owner

Related posts about iphone

Related posts about uiviewcontroller