我正在使用 Xcode 4.5 和 iOS6 为 iPhone 编写一个应用程序。我也在创建一个新的UIWindow
能够管理状态栏的区域(在那里显示消息等)
我正在使用故事板和我的appDelegate
方法如下所示:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
return YES;
}
消息没有出现当我将其放入名为的方法中时,在控制台中viewDidAppear
:
- (void)viewDidAppear:(BOOL)animated {
if (!window) {
window = [[SGStatusBar alloc] initWithFrame:CGRectZero];
window.frame = [[UIApplication sharedApplication] statusBarFrame];
window.alpha = 0.5f;
[self.view.window makeKeyAndVisible]; // has to be main window of app
window.hidden = NO;
}
}
同样的方法,放入viewDidLoad
在控制台中给出警告:
2012-12-27 11:34:20.838 NewApp[433:c07] Application windows are expected to have a root view controller at the end of application launch
这是因为我创建了一个新的UIWindow
?为什么这两种方法之间的差异如此之大?
最重要的是,我怎样才能摆脱这个警告while将代码放入viewDidLoad
method?
EDIT:
我遇到了同样的问题here,但这不是我想要解决它的方式(这实际上是我解决它的方式现在)
我尝试通过执行以下操作将当前的 ViewController 设置为窗口的根视图控制器:
ViewController *vcB = [[UIViewController alloc] init];
window.rootViewController = vcB;
但我不断收到一条警告:
Incompatible pointer types initializing 'ViewController *__strong' with an expression of type 'UIViewController *'