【发布时间】:2015-07-27 16:34:12
【问题描述】:
您好,我开始了一个空白的 ionic 项目。在 app.js 文件中有这段代码:
// Ionic Starter App
// angular.module is a global place for creating, registering and retrieving Angular modules
// 'starter' is the name of this angular module example (also set in a <body> attribute in index.html)
// the 2nd parameter is an array of 'requires'
angular.module('starter', ['ionic'])
.run(function($ionicPlatform) {
$ionicPlatform.ready(function() {
// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
// for form inputs)
if(window.cordova && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
}
if(window.StatusBar) {
StatusBar.styleDefault();
}
});
})
据我了解,上面的代码确实做了两件事。它隐藏了键盘上方的附件栏。并将您的状态栏样式设置为默认样式。
看起来两者似乎都不起作用。当我测试我的应用程序时,离子视图应用程序附件栏仍然存在。
当我从
更改状态栏样式代码的一部分时StatusBar.styleDefault();
到
StatusBar.overlaysWebView(true); StatusBar.styleLightContent();
状态栏还是默认样式(深色),我想要浅色的状态栏。
我是做错了什么,是我遗漏了什么,还是我理解上面的代码有误。
谢谢!!
config.xml:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<widget id="com.ionicframework.testapp582099" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>test_app</name>
<description>
An Ionic Framework and Cordova project.
</description>
<author email="hi@ionicframework" href="http://ionicframework.com/">
Ionic Framework Team
</author>
<content src="index.html"/>
<access origin="*"/>
<preference name="webviewbounce" value="false"/>
<preference name="UIWebViewBounce" value="false"/>
<preference name="DisallowOverscroll" value="true"/>
<preference name="BackupWebStorage" value="none"/>
<feature name="StatusBar">
<param name="ios-package" value="CDVStatusBar" onload="true"/>
</feature>
</widget>
【问题讨论】:
-
打开键盘时应该隐藏状态栏的代码是什么??
-
if(window.cordova && window.cordova.plugins.Keyboard) { cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true); } - 它在我问题的第一个代码块中
-
这会隐藏:使用下一个、上一个和完成按钮隐藏键盘附件栏。这与状态栏无关,链接到以下插件github.com/driftyco/ionic-plugin-keyboard
-
要隐藏状态栏,您需要使用 Statusbar.hide (请参阅此处的文档:github.com/apache/cordova-plugin-statusbar)
-
@aorfevre 抱歉,我知道,我粘贴了错误的代码。 if(window.StatusBar) { StatusBar.overlaysWebView(true);状态栏.styleLightContent(); } - 这应该将状态栏更改为白色文本
标签: javascript ionic-framework statusbar