【问题标题】:how to fix status bar overlap issue in ios 7如何修复 iOS 7 中的状态栏重叠问题
【发布时间】:2014-11-05 00:46:10
【问题描述】:

我正在开发一个在 IOS6 中运行良好的应用程序。但在iOS7中,状态栏与视图重叠。

例如:

我首先需要状态栏,然后我的图标和删除最后。所以请告诉我有关如何删除重叠的任何想法。

但我需要这个

请告诉我有关我的问题的任何想法

【问题讨论】:

    标签: ios objective-c ios7 ios6 statusbar


    【解决方案1】:

    Xcode 具有专门用于解决此问题的 iOS 6/7 Deltas。您必须将视图向下移动 20 像素才能在 iOS 7 上看起来正确,为了使其与 iOS 6 兼容,您将 Delta y 更改为 -20。

    在 iOS 6 上正确调整视图的高度您必须设置 Delta 高度以及 Delta Y。

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

    【讨论】:

    • Sonthos Sharma 感谢您的回复,但我没有使用故事板。所以请给我任何想法。如何以编程方式解决此问题'
    • 没有情节提要也可以。打开你的 .xib 文件删除自动布局检查之后你可以设置你的 delta y。
    • 你也可以看到这个答案 - stackoverflow.com/questions/18775874/…
    【解决方案2】:
     -(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);
        }
      }
    }
    

    【讨论】:

    • 将此代码添加到您的视图控制器中,如果您以编程方式添加它对您来说可以正常工作,如果您使用导航栏使用 santhosh 佛法代码,则可以使用 xib 或 storybaord
    【解决方案3】:

    试试这个代码。在你的 AppDelegate.m 中使用这个代码来完成启动:

    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);
    }
    

    【讨论】:

    • 感谢您的回复,我按照您所说的进行了尝试,但它仅适用于 MainViewControl 视图,但其余视图不起作用所以请给我任何想法
    • 你能检查你的 UIViewController 是否嵌入在 UINavigationController 中。
    • 我没有添加 NaivigationController
    • ok.try 这样添加到每个视图控制器来解决- (void)viewDidLayoutSubviews { [super viewDidLayoutSubviews]; self.window.frame = CGRectMake(0,20,self.window.frame.size.width,self.window.frame.size.height-20);}
    【解决方案4】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-05-13
      • 2014-10-25
      • 2015-01-21
      • 2013-09-24
      • 2013-11-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多