Popping View Controller causes Bar Button Item to disappear

| | August 7, 2015

I have two ViewControllers in my app. The first ViewController (say, ViewControllerOne) has a Bar Button Item that has a slide in TableView (irrelevant to the question). I have disabled the Navigation Bar in the second ViewController (say, ViewControllerTwo) and added a custom view and a Button. I have written the code to pop ViewControllerTwo in thee action of the button. But once it is popped, the BarButton Item in ViewControllerOne disappears.
here is the code I have written in ViewControllerTwo

[self.navigationController setNavigationBarHidden:YES animated:YES];

And

- (IBAction)backCustom:(id)sender 
{
   [self.navigationController popViewControllerAnimated:YES];
}

Any idea why the Bar Button Item would disappear because of this? I am sure this code is the reason because, When I remove it, it runs fine with the default NavigationBar.But I need a custom one for my project

One Response to “Popping View Controller causes Bar Button Item to disappear”

  1. in your first Viewcontroller add the following line

    -(void)viewWillAppear:(BOOL)animated{
    
    [super viewWillAppear:animated];
    
    [self.navigationController setNavigationBarHidden:NO animated:YES];
    }
    

Leave a Reply