When using popToRootViewController I lose my navigation bar

拈花ヽ惹草 提交于 2019-12-10 18:21:19

问题


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.

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!


回答1:


In viewWillAppear of your rootViewControler

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


来源:https://stackoverflow.com/questions/18456189/when-using-poptorootviewcontroller-i-lose-my-navigation-bar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!