uitableviewios8uinavigationitembackbarbuttonitem

Popping View Controller Results in Odd navigationItem / backBarButtonItem Title Swap


Trying to update an app for iOS 8.

I have a set of UITableViews, we'll call them view #1, view #2, and view #3.

When passing from view #2 to view #3, I load view #3 and then pop view #2 off the stack.

In view #2, I am using this code:

// Load an instance of view #3 
ViewThree *viewController = [[ViewThree alloc] initWithNibName:@"ViewThree" bundle:nil];
UINavigationController * navigationController = self.navigationController;       

// Push view #3 to the top of the stack
[navigationController pushViewController:viewController animated:YES];

// Now pop view #2 from the stack
NSMutableArray *navigationArray = [[NSMutableArray alloc] initWithArray:navigationController.viewControllers];
[navigationArray removeObjectAtIndex:1];  
navigationController.viewControllers = navigationArray;

As far as pushing and popping the views, this works fine.

My problem is that when view #3 appears, the navigationItem.title assigned to view #3 slides to the left, turns blue, and takes over the space reserved for the backBarButtonItem (the Back button).

The text seems to respond to my touch, but it does not return to screen #1. I have to kill the app in order to get out of the screen.

This appears to be happening on my iPod Touch running 8.0 from Sep 9th, but does not seem to be happening on my Xcode Simulator from Sept 9th.

Any thoughts about what is going on here? This does not happen on iOS 7.


Update: I thought I half-solved this issue by removing the NavBar Title, but now the < Back button appears, but about 50% of the time it does not work. The user taps the button, the arrow portion of the button turns light blue, and the user is stuck on the screen. The only way to get out is to kill the app.


Solution

  • My guess is: because you change stack while

    // Push view #3 to the top of the stack
    [navigationController pushViewController:viewController animated:YES];
    

    is ongoing (animated push) and UI operations are not thread safe you end up with malformed view stack.

    What you can try to check is:

    1. change animated to NO
    2. remove view #2 from stack in viewDidAppear of view #3