0

Previous Title: 在状态栏上旋转自定义 UIWindow 会导致在 iOS 6 旋转期间显示黑条

我创建了一个自定义 UIWindow,将其放置在具有透明背景颜色的状态栏上。

旋转时,出现黑条,我不知道为什么:

在此处输入图像描述 在此处输入图像描述

这只发生在iOS 6上,而我的iOS 5设备不显示黑条。

AppDelegate中,我创建了一个UIWindow

@property (strong, nonatomic) GRWStatusBarOverlayWindow *statusBarWindow;

CGRect statusBarFrame = [[UIApplication sharedApplication] statusBarFrame];
self.statusBarWindow = [[GRWStatusBarOverlayWindow alloc] initWithFrame:statusBarFrame];
self.statusBarWindow.hidden = NO;

我将状态栏窗口的rootViewController设置为虚拟UIViewController

@interface GRWStatusBarRootViewController : UIViewController

@interface      GRWStatusBarOverlayWindow : UIWindow
@implementation GRWStatusBarOverlayWindow

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
    {
        self.rootViewController = [[GRWStatusBarRootViewController alloc] initWithNibName:nil bundle:nil];

        self.windowLevel = UIWindowLevelStatusBar + 1.0f;
        self.frame = frame;

        self.statusBarView = [[UIView alloc] initWithFrame:frame];
        self.statusBarView.backgroundColor = [UIColor colorWithRed:1.0 green:0.0 blue:0.0 alpha:0.25];
        [self addSubview:self.statusBarView];
    }
    return self;
}

我尝试过使用和不使用 Nib 以及其他一些方法,但都没有完全成功。

我得到的最接近的是如果我离开rootViewController nil,然后我确实得到没有黑条的旋转,但是我确实收到一条消息:

Application windows are expected to have a root view controller at the end of application launch

我总是更喜欢干净的构建和执行,没有任何错误或警告,所以我想找到一个解决方案来删除该消息和黑条。但是,如果该消息是无害的,我会接受它,尽管我不得不想知道未来可能会导致什么其他问题。

有人对这个问题有任何见解吗?任何指导或方向将不胜感激。

4

0 回答 0