0

When I take a picture with Camera plugin, the whole WebView becomes shorter. It's like the screen is being eaten from bottom for the height of the status bar - 20px. It doesn't have to do with taking a picture at all, it also happens if I only open gallery and then close it. The same thing happens if I open InAppBrowser and then close it. Here is an example:

This is how it looks before choosing a photo

This is how it looks before choosing a photo

Then the photo choosing dialog appears (doesn't matter if it's emulator, it behaves the same on the real device)

Then the photo choosing dialog appears (doesn't matter if it's emulator, it behaves the same on the real device)

And then this happens when I close the dialog - look at the bottom of the screen

And then this happens when I close the dialog - look at the bottom of the screen

And if I continue to add photos, each time the screen gets 'eaten' by 20px

And if I continue to add photos, each time the screen gets 'eaten' by 20px

I found out that the window.innerHeight is getting reduced by 20px, so it has something to do with the status bar. How can I fix this?

tuks
  • 800
  • 3
  • 11
  • 27

1 Answers1

0

I stumbled upon the answer in another thread. Here it is:

In MainViewController.h:

@interface MainViewController : CDVViewController
@property (atomic) BOOL viewSizeChanged;
@end

In MainViewController.m:

@implementation MainViewController

@synthesize viewSizeChanged;

[...]

- (id)init
{
    self = [super init];
    if (self) {
        // On init, size has not yet been changed
        self.viewSizeChanged = NO;
        // Uncomment to override the CDVCommandDelegateImpl used
        // _commandDelegate = [[MainCommandDelegate alloc] initWithViewController:self];
        // Uncomment to override the CDVCommandQueue used
        // _commandQueue = [[MainCommandQueue alloc] initWithViewController:self];
    }
    return self;
}

[...]

- (void)viewWillAppear:(BOOL)animated
{
    // View defaults to full size.  If you want to customize the view's size, or its subviews (e.g. webView),
    // you can do so here.
    // Lower screen 20px on ios 7 if not already done
    if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7 && !self.viewSizeChanged) {
        CGRect viewBounds = [self.webView bounds];
        viewBounds.origin.y = 20;
        viewBounds.size.height = viewBounds.size.height - 20;
        self.webView.frame = viewBounds;
        self.viewSizeChanged = YES;
    }
    [super viewWillAppear:animated];
}

Source: https://stackoverflow.com/a/19407903/1555838

Community
  • 1
  • 1
tuks
  • 800
  • 3
  • 11
  • 27