Rom*_*nce 67
如果您正在使用故事板,则可以解决此问题,如此问题:iOS 7 - 状态栏与视图重叠
如果你不使用的故事板,那么您可以在您使用此代码AppDelegate.m中did finishlaunching:
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) {
[application setStatusBarStyle:UIStatusBarStyleLightContent];
self.window.clipsToBounds =YES;
self.window.frame = CGRectMake(0,20,self.window.frame.size.width,self.window.frame.size.height-20);
}
Run Code Online (Sandbox Code Playgroud)
另请参阅此问题:IOS7中的状态栏和导航栏问题
Gim*_*imi 50
在MainViewController.m里面:- (void)viewWillAppear:(BOOL)animated添加:
//Lower screen 20px on ios 7
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) {
CGRect viewBounds = [self.webView bounds];
viewBounds.origin.y = 18;
viewBounds.size.height = viewBounds.size.height - 18;
self.webView.frame = viewBounds;
}
Run Code Online (Sandbox Code Playgroud)
所以end函数看起来像这样:
- (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 = 18;
viewBounds.size.height = viewBounds.size.height - 18;
self.webView.frame = viewBounds;
}
[super viewWillAppear:animated];
}
Run Code Online (Sandbox Code Playgroud)
小智 9
我在打开带有phonegap的inApp浏览器时遇到了问题.Gimi的修复效果很好,但每次打开inApp浏览器时,屏幕都会在底部缩小.所以我添加了一个if语句来检查webview的y origin是否为0.InApp浏览器不再具有y origin 0,所以它解决了我的问题.
// 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];
}
Run Code Online (Sandbox Code Playgroud)
解决方案不是我的,但我找不到来源.希望能帮助到你!
将此代码段放在MainViewController.mphonegap项目的文件中.
- (void)viewDidLayoutSubviews{
if ([self respondsToSelector:@selector(topLayoutGuide)]) // iOS 7 or above
{
CGFloat top = self.topLayoutGuide.length;
if(self.webView.frame.origin.y == 0){
// We only want to do this once, or
// if the view has somehow been "restored" by other code.
self.webView.frame = CGRectMake(self.webView.frame.origin.x,
self.webView.frame.origin.y + top,
self.webView.frame.size.width,
self.webView.frame.size.height-top);
}
}
}
Run Code Online (Sandbox Code Playgroud)
小智 5
我在ViewDidLoad方法中使用此代码.
if ([self respondsToSelector:@selector(edgesForExtendedLayout)])
{
self.edgesForExtendedLayout = UIRectEdgeNone;
}
Run Code Online (Sandbox Code Playgroud)
这在尝试支持以前的iOS版本时也有效.
如果您正在开发iOS 7,我不建议将状态栏包装在黑色矩形旧iOS风格中.只需将其集成到设计中,即可获得更多iOS 7"全屏"外观.
您可以使用此插件调整状态栏的墨水颜色,或隐藏它或在应用程序的任何实例中显示它.
https://github.com/jota-v/cordova-ios-statusbar
js方法是:
window.plugins.statusBar.hide();
window.plugins.statusBar.show();
window.plugins.statusBar.blackTint();
window.plugins.statusBar.whiteTint();
Run Code Online (Sandbox Code Playgroud)
重要提示:同样在您的应用程序plist文件中设置UIViewControllerBasedStatusBarAppearance为NO.
实际上,我发现Gimi的答案是最好的答案,而且我一直在寻找很多东西!只是为了添加Gimi的答案,并回答ignacio-munizaga对该答案的回复,代码将在视图出现时执行,这意味着在您关闭内联浏览器之后,或在相机滚动等之后,所以我只是将bool值说明尺寸是否已经调整过.
最终代码如下:
bool sizeWasAdjusted = false;
- (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 (!sizeWasAdjusted && [[[UIDevice currentDevice] systemVersion] floatValue] >= 7) {
CGRect viewBounds = [self.webView bounds];
viewBounds.origin.y = 18;
viewBounds.size.height = viewBounds.size.height - 18;
self.webView.frame = viewBounds;
sizeWasAdjusted = true;
}
[super viewWillAppear:animated];
}
Run Code Online (Sandbox Code Playgroud)
尝试(app name)-Info.plist在XCode中进入应用程序的文件并添加密钥
view controller-based status bar appearance: NO
status bar is initially hidden : YES
Run Code Online (Sandbox Code Playgroud)
这对我来说似乎没有问题.
| 归档时间: |
|
| 查看次数: |
107239 次 |
| 最近记录: |