电话间隙/窗口显示缩小(更改高度) - 底部出现一条白线



我有最奇怪的事情 - 我正在使用 phonegap/cordova 3.3 - ios

每次我使用使用显示器的插件时,例如相机、视频、扫描仪、窗口显示缩小,屏幕底部出现一条白线。

如果我多次使用该插件(例如拍摄几张照片),窗口会变得越来越小。

它发生在phonegap 2.9和3.3中,仅在ios中。

我遇到了同样的问题,完全相同的问题。

以下是我解决它的方式(现在它可以工作):我恢复了以前一样的viewWillAppear函数/方法:

- (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];
}

而是继续将不同的函数 viewDidLoad 更改为以下内容:

- (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];
}

这里的区别在于,viewDidLoad 只会执行一次(您实际想要的),而每次向用户显示/呈现此视图时都会执行 viewWillAppear。

我希望这有所帮助。

这是由我试图解决的另一个问题引起的,这是原始问题: iOS 7状态栏重叠UI

解决方案是更改 viewWillAppear 如下(在 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];
}

最新更新