Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Phonegap status bar overlaps after inapppbrowser or camera closed

I am using the cordova status bar plugin, it works great until I open an inappbrowser or open a camera, after that it overlaps the app.

I have tried following methods:-

<preference name="fullscreen" value="false" />

 Add 20px margin, but that only works when the above scenario is encountered, else it shows blank 20px space (Used with cordova plugin)
like image 854
Satpal Tanan Avatar asked Mar 01 '17 09:03

Satpal Tanan


3 Answers

Try doing the following to restore the hidden overlap:

StatusBar.overlaysWebView(true);
StatusBar.overlaysWebView(false);
like image 89
Nico Westerdale Avatar answered Oct 21 '22 04:10

Nico Westerdale


i have solved this using this code after camera is closed.

    $cordovaStatusbar.overlaysWebView(true);
    $cordovaStatusbar.overlaysWebView(false);

Btw, i'm using ngCordova.

like image 38
bobsouza Avatar answered Oct 21 '22 04:10

bobsouza


EDIT:

This was fixed in the StatusBar plugin

Currently the NPM registry has only the version 2.4.3 of the cordova-plugin-statusbar. The fixed landed in the Master branch

So basically for ionic people this would mean you need to add it like this (maybe remove it before):

ionic cordova plugin add https://github.com/apache/cordova-plugin-statusbar#master

This installs the master branch from github as plugin for you.

Then run something like this to get it into your Xcode project:

ionic cordova build ios --no-build --prod

Original Post

While calling in JavaScript the method overlaysWebView with true and false works, I assume the proper way would be to call the setNeedsStatusBarAppearanceUpdate method natively when the view disappears.

CDVCamera.m https://github.com/apache/cordova-plugin-camera/blob/master/src/ios/CDVCamera.m#L751

- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];

    [self setNeedsStatusBarAppearanceUpdate];
}

Right now only viewWillAppear is implemented.


BTW: Maybe someone knows why the hiding transition of the statur bar works with following code (in the viewWillAppear method):

SEL sel = NSSelectorFromString(@"setNeedsStatusBarAppearanceUpdate");
if ([self respondsToSelector:sel]) {
    [self performSelector:sel withObject:nil afterDelay:0];
}

but not with the following:

[self setNeedsStatusBarAppearanceUpdate];

And in the viewWillDisappear it works only if the afterDelay is left out with the performSelector or the [self setNeedsStatusBarAppearanceUpdate]; is called.

like image 21
Stefan Rein Avatar answered Oct 21 '22 05:10

Stefan Rein