Using StatusBar plugin works on simulator, not device

160 Views Asked by At

I'm at my wits end at this point, trying to get past the IOS7 issue whereby the statusbar overlaps the top of my app. The steps I've taken are:

  • phonegap plugins add org.apache.cordova.statusbar
  • Adding the following to my main config.xml: <gap:plugin name="org.apache.cordova.statusbar"/> <preference name="fullscreen" value="true" /> <preference name="StatusBarOverlaysWebView" value="false" /> <preference name="StatusBarStyle" value="default" /> <feature name="StatusBar"> <param name="ios-package" value="CDVStatusBar" onload="true" /> </feature>
  • From reading various SO posts, I've tried several times adding/removing both the plugin and the ios platform.

The plugin now successfully adjusts the status bar behavior on the simulator (running cordova run ios) but when I use Phonegap Build to actually run it on the device, alas the status bar still overlays my app webview.

Thanks in advance for the help.

1

There are 1 best solutions below

4
paulvs On

You can open up MainViewController.c (I think that's what it's called in Cordova), find the viewDidLoad: method and insert code like this:

if (IS_IOS7_OR_LATER) {
    CGRect *frame = self.webview.frame;
    frame = CGRectMake(0, 20, frame.size.width, frame.size.height);
    self.webview.frame = frame;
}

where IS_IOS7_OR_LATER is a macro or some other code to check if we're running on iOS 7 or later.