0
votes

A strange problem only occurs on iOS 6.0. In iPad portrait mode of an app based on UISplitViewController, The master view is navigation controller based. The first view controller of the master view has toolbar buttons showed, if I push a second view controller and hide the toolbar, then after pop the second view controller, the buttons on the toolbar of the first view controller is missing forever.(that is, a blank toolbar was shown). The toolbar buttons are initilized in the viewDidLoad of the first view controller. And the toolbar was hide by calling [self.navigationController setToolbarHidden:YES] in the viewDidLoad of the second view controller, and the toolbar was shown again by calling [self.navigationController setToolbarHidden:NO] in viewWillAppear of the first viewcontroller.

Any suggestion? And what's the correct way to hide/unhide toolbar in navigation controller?

By the way it's fine on iOS 4.3, 5.1.1, and fine on iOS 6.0 landscape mode on iPad. This problem only occurs in iOS 6.0 portrait mode in iPad.

Edit: on iPhone, ios 6.0, the same problem. However, fine on landscape mode of iPad with iOS 6.0.

1

1 Answers

1
votes

Since this problem also occurs on iPhone with iOS 6.0, so it might not be related to UISplitView portrait mode.(although UISplitView landscape mode is fine).

So I focus on the toolbar show/hide of UINavigationController, and this thread(Toolbar in Navigation Controller) solved my problem.

I removed setToolBarHidden code in viewDiDLoad and viewWillAppear, and implement UINavigationController delegate protocol:

- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    BOOL shouldHide = [viewController.toolbarItems count] == 0;
    [navigationController setToolbarHidden:shouldHide animated:animated];
}

Now it works. However, I still don't know why the original code just doesn't work on iOS 6.0 on iPhone and iPad portrait mode.