简体   繁体   English

cordova-plugin-statusbar不起作用,有任何可行的解决方法?

[英]cordova-plugin-statusbar not working, any working workaround?

I'm working on a cordova/jquerymobile app that I'm testing on my iPhone device. 我正在使用在iPhone设备上测试的cordova / jquerymobile应用程序。 By now is working great and I have these plugins installed: cordova-plugin-device 1.1.1 "Device" cordova-plugin-dialogs 1.2.0 "Notification" cordova-plugin-whitelist 1.2.1 "Whitelist" phonegap-plugin-push 1.5.3 "PushPlugin" 到目前为止,它运行良好,我已经安装了以下插件:cordova-plugin-device 1.1.1“设备” cordova-plugin-dialogs 1.2.0“ Notification” cordova-plugin-whitelist 1.2.1“ Whitelist” phonegap-plugin-push 1.5.3“推送插件”

The status bar, of course overlays the header as known. 当然,状态栏覆盖了标题。 I just added a <br> in the header div: just for testing is enough. 我只是在标题div中添加了<br> :仅用于测试就足够了。

Now I added the cordova-plugin-statusbar 2.1.2 "StatusBar" to fix this problem since I want to add a back button in the header and the <br> tag doesn't affect the back button that goes in the right left corner with this code: 现在,我添加了cordova-plugin-statusbar 2.1.2“ StatusBar”来解决此问题,因为我想在标题中添加一个后退按钮,并且<br>标记不会影响右上角的后退按钮使用此代码:

<a href="#" id="mybackbtn" class="ui-btn-left ui-btn ui-btn-inline ui-mini ui-corner-all" style="display:none;">Back</a>

I can't understand very well the documentation on https://github.com/apache/cordova-plugin-statusbar : do I have to add the settings in the config.xml of my cordova directory? 我无法很好地理解https://github.com/apache/cordova-plugin-statusbar上的文档:我必须在我的cordova目录的config.xml中添加设置吗? or in the platform directory? 或在平台目录中? or in the onDeviceReady function? 或在onDeviceReady函数中?

I tried all 3 ways but when I run on my device from Xcode I get this error in the console: 我尝试了所有3种方法,但是当我从Xcode在设备上运行时,在控制台中出现此错误:

THREAD WARNING: ['Device'] took '23.845215' ms. 螺纹警告:['设备']花费了'23 .845215'毫秒。 Plugin should use a background thread. 插件应使用后台线程。

The app is frozen, others plugin are not working and I can't even tap on a button or do anything. 该应用程序被冻结,其他插件不起作用,我什至无法点击按钮或执行任何操作。 If I wait the app crashes with this message in console: 如果我等待应用崩溃,并在控制台中显示以下消息:

Message from debugger: Terminated due to memory issue 来自调试器的消息:由于内存问题而终止

Anyway it seems it happens random: if I run the app again from Xcode on device it works fine after a random number of tries. 无论如何,它似乎是随机发生的:如果我从设备上的Xcode再次运行该应用程序,则经过随机尝试多次后,它仍能正常工作。

I tried with this in the index.js 我在index.js中尝试过

onDeviceReady: function() {
            StatusBar.overlaysWebView(false);
            StatusBar.backgroundColorByName("black");
}

or with this in the config.xml in the cordova root directory 或与此一起在cordova根目录下的config.xml中

<preference name="StatusBarOverlaysWebView" value="false" />
<preference name="StatusBarBackgroundColor" value="#000000" />

and the same code in the config.xml in the platforms/ios/myapp/ but the problem is always the same. 和platform / ios / myapp /中config.xml中的相同代码,但问题始终相同。 I'm not even sure in which point of the config.xml file I should add this code, I tried right before the </widget> tag but not sure it's the right place. 我什至不知道应该在config.xml文件的哪一点添加此代码,我在</widget>标记之前尝试过,但不确定是否在正确的位置。

I found that is a known issue, but couldn't find a solution. 我发现这是一个已知问题,但找不到解决方案。 So I was thinking if I could leave my simple <br> tag and move the button in header 20px lower or something... but I don't know exactly how to do it. 因此,我在考虑是否可以保留我的简单<br>标记,并将标题中的按钮降低20像素左右或更多……但我不知道该怎么做。 And anyway I'm sure it's not the right solution due to different ios (android) or different devices (smartphones, tablets, device orientation, etc.) 无论如何,由于不同的ios(android)或不同的设备(智能手机,平板电脑,设备方向等),我确定这不是正确的解决方案

Can u give me any advice or suggest any other solutions you've found? 您能给我任何建议或建议您找到其他解决方案吗? Thank you. 谢谢。

更新您的CLI:

npm install -g cordova

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM