OliverLetterer/ANAdvancedNavigationController — Issue #4: the popViewController could not pop the root right view controller
Author: flypigz
Created: 2011-12-26 14:28:17+00:00
State: open

the popViewController method re-use the popViewControllerToViewControl, which lead to this limitation, it does not support pop all of the right view controllers....

instead, i think the popViewControllerToViewControl should re-use code of popViewController method..

- (void)popViewController:(UIViewController *)viewController animated:(BOOL)animated {
NSLog(@"%s", __PRETTY_FUNCTION__);
if (![self.viewControllers containsObject:viewController]) {
NSLog(@"viewController (%@) is not part of the viewController Hierarchy", viewController);
return;
}

// this method re-use the _popViewControllersToViewController, which require at least
// one left size view controller to specify the location to pop, so it does not
// support poping the root right view controller

NSInteger index = [self.viewControllers indexOfObject:viewController]-1; // why

NSLog(@"index: %d", index); ===> if the root right viewcontroller is passed as parameter, the index is -1 here...

if (index >= 0) {
viewController = [self.viewControllers objectAtIndex:index];
[self _popViewControllersToViewController:viewController animated:animated];
}
}