【问题标题】:Black status bar bug iOS黑色状态栏错误 iOS
【发布时间】:2014-12-02 02:15:29
【问题描述】:

大家。

伙计们,我的项目中的状态栏有问题..

默认情况下,应用状态栏应该隐藏。这是可行的,但是一个视图有一个像屏幕截图一样的状态栏错误。 在主菜单上它是黑色的并且不隐藏(

在单例中,我正在为不同的设备初始化背景图像,这适用于应用程序中的所有视图))

这是我的代码单例初始化背景:

//后台返回 - (UIColor *)mainBackground:(UIInterfaceOrientation)orientation {

    UIColor *color;
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
        if (orientation == UIInterfaceOrientationPortrait || orientation == UIInterfaceOrientationPortraitUpsideDown) {
            color = [UIColor colorWithPatternImage:[UIImage imageNamed:@"backgroundIpad.png"]];
        }
        else if (orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight) {
            color = [UIColor colorWithPatternImage:[UIImage imageNamed:@"backgroundLandspIpad.png"]];
        }
    } else {
        color = [UIColor colorWithPatternImage:[UIImage imageNamed:@"background.png"]];
    }
    return color;
}

//return wight screen
- (float)wightScreen {
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
        UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
        if (orientation == UIInterfaceOrientationPortrait || orientation == UIInterfaceOrientationPortraitUpsideDown) {
            return 768;
        }
        else if (orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight) {
            return 1024;
        }
    }
    return wight();
}

//return rect view all for screens
- (CGRect)refreshPoints {
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
        UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
        if (orientation == UIInterfaceOrientationPortrait || orientation == UIInterfaceOrientationPortraitUpsideDown) {
            return CGRectMake(0, 0, 768, 1024);
        }
        else if (orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight) {
            return CGRectMake(0, 0, 1024, 768);
        }
    } else {
        return CGRectMake(0, 0, 320, height());
    }
    return CGRectMake(0, 0, 768, 1024);
}

这是控制器视图中的代码,我遇到了问题:

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    return [[Singleton sharedInstance] getSelf:@"MainMenuController"];
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
}

- (void)viewDidLoad
{
    [super viewDidLoad];

    [[PostRequest sharedInstance] userInfo];

    self.view.backgroundColor = [[Singleton sharedInstance] mainBackground:[[UIApplication sharedApplication] statusBarOrientation]];

//    if (iphone4()) {
//        [self newRectNiewIphone];
//    }
}

希望能得到你的帮助!

【问题讨论】:

    标签: ios objective-c


    【解决方案1】:

    这是带有错误状态栏的屏幕截图

    http://i.stack.imgur.com/nfiZ3.png

    还有截图,如何查看其他视图

    http://i.stack.imgur.com/wVadC.png

    【讨论】:

      【解决方案2】:

      你需要设置

      self.automaticallyAdjustsScrollViewInsets=NO;
      

      在 viewDidLoad 方法中的 viewController 上。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-08-05
        • 1970-01-01
        • 2014-08-31
        相关资源
        最近更新 更多