[英]Root view controller in a Storyboard
I'm playing around with a single-window template.我在玩一个单窗口模板。 I have a classic
MainStoryboard.storyboard
file and I have only 1 view controller (which is an Initial View Controller all by default)我有一个经典的
MainStoryboard.storyboard
文件,我只有 1 个视图控制器(默认情况下都是初始视图控制器)
What I do is I try to implement the behaviour from this example and the Xcode tells me this:我所做的是尝试实现此示例中的行为,Xcode 告诉我:
Application windows are expected to have a root view controller at the end of application launch
I don't understand what I'm doing wrong.我不明白我做错了什么。 Here's the piece of code where I create a new
UIWindow
:这是我创建新
UIWindow
的一段代码:
UIWindow *overlayWindow = [[UIWindow alloc] init];
overlayWindow = [[ACStatusBarOverlayWindow alloc] initWithFrame:CGRectZero];
overlayWindow.hidden = NO;
And of course my appDelegate
starts with this:当然,我的
appDelegate
是这样开始的:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
return YES;
}
What am I doing wrong?我究竟做错了什么?
You should make your window key and visible by你应该让你的窗口键和可见
[overlayWindow makeKeyAndVisible];
as suggested in the very same example you linked.正如您链接的同一个示例中所建议的那样。
EDIT编辑
This the code you are using这是您正在使用的代码
UIWindow *overlayWindow = [[UIWindow alloc] init];
overlayWindow = [[ACStatusBarOverlayWindow alloc] initWithFrame:CGRectZero];
overlayWindow.hidden = NO;
The first line its useless and potentially it is the one which is causing the warning.第一行没用,可能是导致警告的那一行。 You are creating a
UIWindow
instance and than throwing it away in the next line.您正在创建一个
UIWindow
实例,而不是在下一行中将其丢弃。
Remove it and just do:删除它并执行以下操作:
UIWindow *overlayWindow = [[ACStatusBarOverlayWindow alloc] initWithFrame:CGRectZero];
overlayWindow.hidden = NO;
Also you should assign a root view controller to the newly created window, by您还应该为新创建的窗口分配一个根视图控制器,通过
overlayWindow.rootViewController = self.window.rootViewController;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.