views:

87

answers:

1

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 ?

A: 

Well i Fixed this.

I was trying to poptorootviewcontroller from a viewcontroller that had no view but isntead just displayed a UIImagepickercontroller. Even when attempting to dissmiss this modalviewcontroller first, (even with a delay), i still had the same problem. I instead changed the viewcontroller in question to a UIMagepickercontroller subclass and handle the present and dismiss in another viewcontroller.

Lesson learnt, dont pop to root with UIImagepickercontroller modal view ontop.

Spyker