Search code examples
iosuinavigationcontrolleruinavigationbaruinavigationitem

hidesBackButton / setHidesBackButton not working


I have some problem in my application.

In my application there is a possibility to edit some information (something like iPhone's contacts). When you press 'Edit' button on right of navigation bar, "Back" button should hide, and "Cancel" button appear.

It working perfectly, when user press "Edit" button straight from ViewController.

But, when user creating a new advert, the view controller with editing should open, in edit mode. I call it this way:

VICarInfo * vc = [[VICarInfo alloc] init];
[vc setCurrentAdv:adv];
[self.navigationController pushViewController:vc animated:YES];

if (editMode) {
    [self.navigationItem setHidesBackButton:YES animated:NO];
    [vc btnEditClick];
}

And "Back" button didn't disappear.

I also tried to hide button in ViewWillAppear, ViewDidLoad or ViedDidLayout subviews, also unsuccessful.

Simulator

Please, give me any advices, how to do it.

Thank you.


Solution

  • I know this is late, but I was seeing the same thing and found a solution.

    It seems that hidesBackButton = YES interferes with setting the leftBarButtonItem(s).

    Don't use hidesBackButton and you'll lose the overlay.

    This seems like a bug, but Apple's own documentation is pretty hazy on the interaction of those two/three properties.