【问题标题】:Status bar not being hidden in Ionic View on iOSiOS 上的 Ionic View 中没有隐藏状态栏
【发布时间】:2017-11-08 20:14:32
【问题描述】:

在我的 Ionic v1.2 应用程序中,我设置了以下内容 (according to the docs):

function Run($rootScope, $state, $http) {
  ...
  ionic.Platform.ready(function() {
    ionic.Platform.fullScreen(true, true);
  });
}

这应该让我的应用全屏显示状态栏。当然,在网络浏览器中预览时看起来不错(使用ionic servehttp-server):

但在 Ionic View 中测试时,状态栏与标题重叠:

是否有一些已知的解决方法?

【问题讨论】:

    标签: ionic-framework ionic-view


    【解决方案1】:

    您需要使用插件 cordova-plugin-statusbar 来实现。

    参考:https://github.com/apache/cordova-plugin-statusbar

    并在您的应用中使用以下代码隐藏状态栏,

    document.addEventListener("deviceready", onDeviceReady, false);
    function onDeviceReady() {
        StatusBar.hide();
    }
    

    【讨论】:

      【解决方案2】:

      除了@Subash 答案之外,您还需要在 Xcode 中设置一些状态栏配置,但诀窍在于您的 plist 文件中。您需要添加值为“NO”的属性“基于控制器的状态栏外观”。希望对您有所帮助!

      【讨论】:

        【解决方案3】:

        你必须安装插件状态栏:

        $ ionic cordova plugin add cordova-plugin-statusbar
        $ npm install --save @ionic-native/status-bar
        

        然后您可以根据需要自定义状态栏:https://ionicframework.com/docs/native/status-bar/

        我建议您将这些行添加到您的代码中,这样您仍然可以在屏幕顶部看到状态栏:

        if (window.StatusBar) {
          Statusbar.overlaysWebView(true);
          StatusBar.style(1); 
        }
        

        【讨论】:

          猜你喜欢
          • 2017-03-20
          • 2017-01-09
          • 2020-02-20
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2016-01-03
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多