Hiding a UINavigationController on start page

会有一股神秘感。 提交于 2020-01-06 13:57:51

问题


Hi I have a navigationController that starts with a view controller in which in viewDidLoad has:

 self.navigationController.navigationBarHidden = YES;

I click a button on that page and it transitions to a second view controller in which I put:

self.navigationController.navigationBarHidden = NO;

This works fine until I click the Back button in the navigation bar. How do I keep the navigation bar permanently off the start page but not the transitioned one?


回答1:


Add self.navigationController.navigationBarHidden = YES; in the viewWillAppear of the firstViewController.

You are adding hidden action in the viewDidLoad method which is called once as the viewControllers in navigation stack are not unloaded when your push to the nextViewController.




回答2:


-(void)viewWillAppear:(BOOL)animated
{

    self.navigationController.navigationBarHidden=YES;
}

Add this code in your .m file whwre you hide the navigation controller.



来源:https://stackoverflow.com/questions/18798075/hiding-a-uinavigationcontroller-on-start-page

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