如何获取iOS状态栏*覆盖*应用程序表面,而不是推下来? [英] How can I get the iOS status bar to *overlay* the app surface rather than pushing it down?

查看:236
本文介绍了如何获取iOS状态栏*覆盖*应用程序表面,而不是推下来?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为iOS(和其他人)开发一个Phonegap应用程序。视图只是景观。我使用PhoneGap Build与PG 3.1。我在iOS7的iPad3上测试。我需要一个解决方案,不仅仅是在iOS7,但也有一些版本回来。

I am developing a Phonegap app for iOS (and others). The view is landscape only. I am using Phonegap Build with PG 3.1. I am testing on an iPad3 with iOS7. I need a solution that works not just on iOS7, but also a couple of versions back.

在Xcode iPad模拟器,应用程序使用整个屏幕。状态栏是透明的,并覆盖在应用程序的顶部。但是,当我在我的iPad上测试应用程序时,状态栏不再透明,并将应用程序下推20px,这意味着底部的20px消失。

In the Xcode iPad emulator, the app uses the entire screen. The status bar is transparent and overlaid on top of the app. However, when I test the app on my iPad, the status bar isn't transparent anymore, and pushes the app down 20px, which means the bottom 20px disappear.

对于这个特定的应用程序,它会更好,如果顶部被覆盖,以便应用程序的重要底部不被推出视图。所以问题是:
我可以使状态栏完全消失,或者可以使其透明和覆盖吗?

For this particular app, it would be much better if the top was overlaid, so that the important bottom part of the app wasn't pushed out of view. So the question is: Can I either make the status bar disappear completely, or can I make it transparent and overlaid?

我试过了状态栏插件的Phonegap,但它似乎无法正常工作。我在我的deviceReady函数中使用StatusBar.hide(),但是栏仍然在视图中。更糟的是,屏幕的右手部分对触摸事件完全无反应。就好像屏幕上有一个透明的叠加层,可能与此错误有关。 。正如所描述的,覆盖是不透明的,但它似乎覆盖了完全相同的区域,在我的情况下无反应。

I have tried the Status Bar plugin for Phonegap, but it doesn't seem to work properly. I used StatusBar.hide() in my deviceReady function, but the bar remained in view. And worse, the right-hand part of the screen became completely unresponsive to touch events. As if there was a transparent overlay on that part of the screen, possibly related to this bug. As described there, the overlay isn't transparent though, but it seems to cover exactly the same area that goes unresponsive in my case.

推荐答案

我在Cordova 3.6 + iOS 7.1中使用了这个工具。考虑到iOS 7和8都有50%的市场份额,这个解决方案应该足够了。

I got this to work beautifully in Cordova 3.6 + iOS 7.1. And considering that iOS 7 and 8 each have 50% of market share this solution should be enough.

插件我使用: org.apache .cordova.statusbar

而不是使用 StatusBar.hide()

var hideSb = function(){
//        StatusBar.hide;
        cordova.exec(null, null, 'StatusBar', 'hide', ['Ehi', 'You']);
    };

fn onDeviceReady 中调用。这是基于:

cordova.exec(
    callbackFn,     // A callback function that deals with the JSON object from the CDVPluginResult instance
    errorFn,        // An error handler
    'TargetClass',  // What class to target messages to (method calls = message in ObjC)
    'methodToCall', // Which method to call
    [ 'array', 'of', 'arguments'] // These go in the CDVInvokedUrlCommand instance's.arguments property
);

我已经经历了在一个函数中包装它,并直接使用它工作有时。此外,我对所通过的参数毫无头绪!

And I've experienced that wrapping it in a function works and just using it straight away doesn't work at times. Also I'm clueless about the arguments passed!

这篇关于如何获取iOS状态栏*覆盖*应用程序表面,而不是推下来?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆