2

I have the strangest thing - I'm using phonegap/cordova 3.3 - ios

Every time I use a plugin that is using the display, e.g. camera, video, scanner, the window display shrinks and a white line appear in the bottom of the screen.

If I uses the plugin several times (e.g. take a few photo) the window is just keep getting smaller and smaller.

It happens both with phonegap 2.9, and 3.3, only in ios.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Elia Weiss
  • 8,324
  • 13
  • 70
  • 110

2 Answers2

3

I had the same problem, with the exact same issue.

Here is how I went about solving it (and now it works): I reverted back the viewWillAppear function/method as it was before:

- (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 ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) {
        CGRect viewBounds = [self.webView bounds];
        viewBounds.origin.y = 20;
        viewBounds.size.height = viewBounds.size.height - 20;
        self.webView.frame = viewBounds;
    }
     */
    [super viewWillAppear:animated];

}

and instead went on changing a different function, viewDidLoad, to the following:

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.

    if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) {
        CGRect viewBounds = [self.webView bounds];
        viewBounds.origin.y = 20;
        viewBounds.size.height = viewBounds.size.height - 20;
        self.webView.frame = viewBounds;
    }

    self.view.backgroundColor = [UIColor blackColor];
}

The difference here is, that the viewDidLoad will be executed only once (what you actually want), while viewWillAppear is executed EVERY time this view is shown/presented to the user.

I hope this helps.

Hrvoje
  • 189
  • 1
  • 7
0

This is caused by another issue I was trying to solve, here is the original issue: iOS 7 status bar overlapping UI

The solution was to change viewWillAppear as follow (in MainViewController.m)

// ios 7 status bar fix
- (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 ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) {
        if(self.webView.frame.origin.y == 0) {
            CGRect viewBounds = [self.webView bounds];
            viewBounds.origin.y = 20;
            viewBounds.size.height = viewBounds.size.height - 20;
            self.webView.frame = viewBounds;
        }
    }

    [super viewWillAppear:animated];
}
Community
  • 1
  • 1
Elia Weiss
  • 8,324
  • 13
  • 70
  • 110