当状态栏最初隐藏时,使用 StatusBar Cordova 插件 show() 不起作用

Using StatusBar Cordova plugin show() doesn't work when status bar initially hidden

我正在使用 Cordova StatusBar 插件:https://github.com/apache/cordova-plugin-statusbar 它运行良好,除非我最初在 iOS 上隐藏状态。

我尝试做的事情:

为此,我按照插件的自述文件中的说明修改了我的 plist。它工作正常,启动启动画面时隐藏状态栏。

但是,当我使用 StatusBar.show() 时,它 没有 工作。状态栏保持隐藏状态。 (我在 deviceready 事件上使用 StatusBar.show()。)

我终于解决了我的问题。我post这里是我发现的,如果有人想实现我所做的同样的事情。

首先请注意,我使用 PhoneGap Build,因此此解决方案适用于该服务。

要在闪屏可见期间隐藏状态栏,您需要修改应用程序的 plist 文件(如此处所述:https://github.com/apache/cordova-plugin-statusbar#hiding-at-startup)。

要在 PhoneGap Build 上实现这一点,您必须将以下行添加到您的 config.xml 文件中:

<gap:config-file platform="ios" parent="UIStatusBarHidden"><true/></gap:config-file>
<gap:config-file platform="ios" parent="UIViewControllerBasedStatusBarAppearance"><false/></gap:config-file>

然后你需要主动显示状态栏。所以在隐藏启动画面时,使用 StatusBar.show();.

setTimeout(function() {
    navigator.splashscreen.hide();
    StatusBar.show(); // Status bar is initially hidden, we need to show it when splashscreen disappears
}, 2000);