Question

I'm building an iOS app that uses a lot of web services. The app has a UItabBarController as its root VC.

In one of my controllers I am pushing a viewController onto a UINavigationController. The ViewController that I am pushing onto the stack is a UITableViewController that has a UITableView with data from the web. I reinstaintiate the controller on each level the user goes down in the data. Then, right at the last level I call a web service and then want the whole UITableViewController to be dismissed and the original view controller to be shown.

This is how it looks:

ViewControllerA (UIViewController) -> user taps a Button - Push ViewControllerB onto it. (UINavigationController).

Once I am done with ViewControllerB I need it to be dismissed and ViewControllerA to be shown with the results.

In ViewControllerB I do something like this in NSNotification method:

if ([errorString hasPrefix:@"No descendants"]){
    UINavigationController *navigationController = 
                     [self.tabBarController.viewControllers objectAtIndex:1];
    BBSearchViewController *searchViewController = 
                     navigationController.viewControllers[0];
    searchViewController.categoryId = self.categoryId;


    if (searchViewController.brwosingCategoriesFromSearchPage){
        [[BBDataStore sharedDataStore]deRegisterForNotifications:self];
        [self.navigationController popToRootViewControllerAnimated:NO];

This causes this error in the console:

> 2014-05-08 09:32:16.306 TestApp[36948:60b] Finishing up a navigation transition 
in an unexpected state. Navigation Bar subview tree might get corrupted.

 2014-05-08 09:32:16.780 TestApp[36948:60b] Unbalanced calls to begin/end 
appearance transitions for <ViewControllerA: 0xd08aa00>.

Can someone tell me what I am doing wrong here?

Was it helpful?

Solution

You're getting these errors because you're attempting one transition before another has finished. In your case, it looks like you're getting the notification before the view has finished appearing and then attempting to pop to root. You should be calling popToRootViewControllerAnimated: using user input (when the user taps a button) or at least after viewDidAppear:.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top