Question

I have an iOS app where the main screen is a UICollectionViewController. When selecting an Item from the collection view the view is pushed to a detail view of the item. In the detail view I built a drawer/slider that moves out from the side. In order to get the view to look the way I wanted I hid the default navigation bar and inserted one via storyboards.

ScreenShot

I ran into an issue that when hiding the default navigation bar you lose the back button functionality that comes with using a navigation controller. I worked around this by adding a button where the back button would have been (the image above is shown without the button). Now I use the line of code below to move back to the collection view.

[self.navigationController popToRootViewControllerAnimated:YES];

It works the way I want it except that I lose my Navigation Bar when I return to the collection view. Does anyone have any thoughts on how to fix this? Thanks in advance!

Was it helpful?

Solution

In viewWillAppear of your rootViewControler

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

OTHER TIPS

I know this thread it's a little dated (more than dated more like an archive). But I ran into the same issue in swift 5, Xcode 13. Below is the swift code that I used in my viewWillAppear in case it helps someone.

self.navigationController?.setNavigationBarHidden(false , animated: true)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top