【问题标题】:Hide UINavigationbar and yet show Status bar on Xamarin.iOS隐藏 UINavigationbar,但在 Xamarin.iOS 上显示状态栏
【发布时间】:2017-10-19 06:30:07
【问题描述】:

我想隐藏 UINavigation Bar 并且只显示 Rootview 控制器的状态栏。 this.NavigationController.SetNavigationBarHidden(true, true);

两者都隐藏。现在它看起来像 this

【问题讨论】:

    标签: xamarin xamarin.ios


    【解决方案1】:

    Status Bar:

    Navigation Bar:

    因此,您的屏幕截图显示了状态栏,但没有显示导航栏。代码可以正常工作。

    有关如何隐藏/显示状态栏和导航栏的更多详细信息,请参阅以下部分:

    1. 要隐藏/显示状态栏,您需要在 info.plist 文件中添加此设置:

      <key>UIViewControllerBasedStatusBarAppearance</key>
      <false />
      

      然后在你的 ViewController 中添加代码:

      UIApplication.SharedApplication.SetStatusBarHidden(true/false,true);
      
    2. 要隐藏/显示导航栏,只需在ViewWillAppear中添加代码:

      this.NavigationController.SetNavigationBarHidden(true/false, true);
      

    【讨论】:

    • 谢谢,在 ViewwillAppear() 中添加要隐藏和显示的两条线就可以了。
    【解决方案2】:

    抱歉,我没有足够的声誉,无法发表评论。

    从您附加的图片和问题中隐藏 UINavigationBar 并仅显示状态栏,看起来它是正确的并且您的代码也是正确的。

    附件是您可能正在寻找的答案:How to hide Navigation Controller in Root View?

    【讨论】:

      【解决方案3】:

      首先检查文件 info.plist 中

      确认未选中隐藏状态栏。如果你想显示状态栏。

      如果解决了您的问题,请告诉我。

      【讨论】:

      • 我通过添加两行解决了这个问题 this.NavigationController.SetNavigationBarHidden(true, true); UIApplication.SharedApplication.SetStatusBarHidden(false, true);在 ViewWillAppear() 中并将其设置在 .plist 中,就像接受的答案一样
      猜你喜欢
      • 2014-04-23
      • 1970-01-01
      • 2014-10-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-09-24
      相关资源
      最近更新 更多