您的位置:首页 > 移动开发

phonegap开发中IOS状态栏与APP重叠问题解决方法

2014-07-21 23:28 477 查看
进行hybird编程,采用方案为phonegap+jqmobile,在IOS7的设备中发现APP界面的顶部与IOS状态栏互相重叠在一起,查看底层源码后发现原因,解决方法如下:

MainViewController.m 文件一处代码修改即可:

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

注意:

viewBounds.origin.y =20;
viewBounds.size.height = viewBounds.size.height -20;
这两行代码应在程序生命周期中只执行一次,切勿多次执行,因为对phonegap来说,进入拍照状态再回到原程序,会再次执行viewWillAppear函数,所以如果不特殊处理便会执行多次,从而导致页面被压缩!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: