嗨,我开始了一个空白的离子项目。在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(真); 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>
答案 0 :(得分:1)
添加插件后它应该可以工作:
$ cordova plugin add org.apache.cordova.statusbar
由于某些原因,即使在代码中使用了插件,插件也不会自动安装在Ionic入门项目中。更多信息:http://learn.ionicframework.com/formulas/customizing-the-status-bar/
要在Ionic View中使用此功能,您可能需要做更多工作。
ng-cordova.js
在 angular.js
和cordova.js
之间生活。如果你想使用更多的ngCordova插件,这无论如何都不是很糟糕。 angular.module('myApp', ['ngCordova'])
$ cordova plugin add cordova-plugin-statusbar
。首先要删除上面的插件(它们可能也可能不一样......)。$cordovaStatusbar
注入.run
块(如果需要,还可以注入控制器等)。$cordovaStatusbar.hide()
。$ionicPlatform.ready
,则可能无法在Ionic View中按预期工作(请参阅:https://github.com/driftyco/ionic-view-issues/issues/52)。要使其正常工作,请将其包装在$timeout
中,或者
因此,如果您对小型黑客不感兴趣,则在离子加载之前将
<script>window.phonegap = {}</script>
添加到您的<head>
应该强制它等待设备已准备好的事件而不会踩到Cordova&#39; s一旦它加载了脚趾。比在任何地方写$ timeout都简单得多。