我有最奇怪的事情 - 我正在使用phonegap / cordova 3.3 - ios
每次我使用使用显示器的插件时,例如相机,视频,扫描仪, 窗口显示收缩,屏幕底部出现白线。
如果我多次使用该插件(例如拍几张照片),窗口就会越来越小。
只有在ios中才会出现phonegap 2.9和3.3。
答案 0 :(得分:3)
我遇到了同样的问题,问题完全相同。
以下是我如何解决它(现在它的工作原理): 我恢复了之前的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。
我希望这会有所帮助。
答案 1 :(得分:0)
这是由我试图解决的另一个问题引起的,这是原始问题:iOS 7 status bar overlapping 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];
}