How to hide navigation bar in iPhone?

后端 未结 7 546
悲&欢浪女
悲&欢浪女 2021-01-16 04:55

Currently i am working in iPhone app, I have two screen like A and B, A has no navigation bar, but B has navigation bar. so i set like this.

Class A:



        
7条回答
  •  礼貌的吻别
    2021-01-16 05:04

    You'll need to use this code:

    [navigationController setNavigationBarHidden: YES animated:YES]

    in - (void)viewWillAppear:(BOOL)animated or later in the view lifecycle in both classes. [Avoid doing this in - (void)viewDidLoad.]

    The trick here is in using the setNavigationBarHidden:animated: method (in place of the simpler setNavigationBarHidden: method). This will ensure your UI issue goes away and also any positional issues due to it.

    P.S. Check the value of self.navigationController.navigationBarHidden (instead of self.navigationController.navigationBar.hidden) if you need to check if your navigation bar is hidden, at some point, in your code.

提交回复
热议问题