在iOS 7中,Phonegap应用程序将出现在状态栏下方。这会使点击已放置在屏幕顶部的按钮/菜单变得困难。
有没有人知道如何在iOS 7的Phonegap应用程序中解决这个状态栏问题?
我试着用CSS来偏移整个网页,但似乎不起作用。有没有一种方法可以偏移整个UIWebView,或者只是让状态栏表现得像iOS6一样?
谢谢
发布于 2013-10-08 21:59:05
我在另一个帖子上找到了答案,但我会回答这个问题,以防其他人想知道。
只需将MainViewController.m
中的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];
}
发布于 2013-11-10 07:16:40
除了Ludwig Kristoffersson的调整大小修复之外,我还建议更改状态栏颜色:
- (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];
}
-(UIStatusBarStyle)preferredStatusBarStyle{
return UIStatusBarStyleLightContent;
}
发布于 2014-04-16 17:35:51
请安装phonegap的插件:https://build.phonegap.com/plugins/505
并使用如下所示的正确设置来控制webview的覆盖:
<preference name="StatusBarOverlaysWebView" value="false" />
对我来说,使用Phonegap 3.3.0就可以了。
更多信息,请访问Github项目页面:https://github.com/phonegap-build/StatusBarPlugin
https://stackoverflow.com/questions/19209781
复制相似问题