2014-09-11 50 views
3

我正在开发一个在IOS6中工作正常的应用程序。但在iOS7中,状态栏与视图重叠。如何解决状态栏重叠问题在IOS 7

举个例子: IOS7

我需要状态栏第一和然后我的图标,并删除最后。所以请给我有关如何删除重叠的想法。

但我需要这个

enter image description here 请给我任何想法,我的问题

回答

3
-(void)viewWillLayoutSubviews{ 

if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) 
    { 
    self.view.clipsToBounds = YES; 
    CGRect screenRect = [[UIScreen mainScreen] bounds]; 
    CGFloat screenHeight = 0.0; 
    if(UIDeviceOrientationIsPortrait([[UIApplication sharedApplication] statusBarOrientation])) 
     screenHeight = screenRect.size.height; 
    else 
     screenHeight = screenRect.size.width; 
    CGRect screenFrame = CGRectMake(0, 20, self.view.frame.size.width,screenHeight-20); 
    CGRect viewFr = [self.view convertRect:self.view.frame toView:nil]; 
    if (!CGRectEqualToRect(screenFrame, viewFr)) 
    { 
     self.view.frame = screenFrame; 
     self.view.bounds = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height); 
    } 
    } 
} 
+0

添加此代码到你的视图控制器,如果你添加编程它工作正常,如果你使用导航栏使用santhosh达摩尔代码,它会很好使用xib或storybaord – 2014-09-17 06:51:14

5

Xcode具有一个专门用来解决此问题的iOS 6/7三角洲。您必须将视图向下移动20个像素才能在iOS 7上正确显示,并且为了与iOS 6兼容,您将Delta y更改为-20。

enter image description here

调整的正常在iOS 6次的高度,您必须设置三角洲高度以及三角洲Y.

你也可以看到这一点 - Fix iOS 7 Status bar overlapping

+0

Sonthos夏尔马感谢答复,但我不使用故事board.So请给我任何idea.How以编程方式解决这个问题' – 2014-09-11 07:25:08

+0

它可以做到没有故事板。打开你的.xib文件删除自动布局检查后,你可以设置你的delta y。 – 2014-09-11 07:28:34

+0

你也可以看到这个答案 - http://stackoverflow.com/questions/18775874/ios-7-status-bar-overlaps-the-view – 2014-09-11 07:32:07

-1

这是默认行为为iOS 7上的UIViewController。该视图将全屏,状态栏将覆盖视图的顶部。如果隐藏了navigationBar,则必须通过移动20个点来调整所有UIView元素。

1

试试这个code.use这个代码在你AppDelegate.m在做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); 
} 
+0

感谢您的回复我试着如你所说,但它的工作只有MainViewControl视图,但其余视图不工作所以请给我任何想法 – 2014-09-11 08:24:20

+0

检查此链接.http://stackoverflow.com/questions/18980925/status-bar-and-导航栏问题在ios7 – 2014-09-11 09:24:48

+0

谢谢我会尝试 – 2014-09-11 09:43:44