简体   繁体   English

iOS5:如何在UIStoryboard中设置UIWindow子类?

[英]iOS5: How to set UIWindow subclass in UIStoryboard?

Since there seems to be no window settings in UIStoryboard editor, I want to know how to switch the AppDelegate's window class from UIWindow to its subclass. 由于UIStoryboard编辑器中似乎没有窗口设置,我想知道如何将AppDelegate的窗口类从UIWindow切换到其子类。

What I often do is writing the following codes in application:didFinishLaunchingWithOptions:, but each time it really makes me dull. 我经常做的是在应用程序中编写以下代码:didFinishLaunchingWithOptions :,但每次它真的让我变得迟钝。

UIViewController* vc = self.window.rootViewController;
self.window = [[MyWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.rootViewController = vc;

Any ideas? 有任何想法吗?

You are doing the right thing. 你正在做正确的事。 That is the way to customize your window. 这是自定义窗口的方法。 Setting it in IB is just as cumbersome, if you think about it. 如果你想一想,在IB中设置它就像麻烦一样。

If you are dulled by the prospect of typing these three lines of code, consider the convenient feature of the Code Snippets Library in Xcode. 如果您对键入这三行代码的前景感到迟钝,请考虑Xcode中代码片段库的便捷功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM