iOS5:如何在UIStoryboard中设置UIWindow子类?
由于UIStoryboard编辑器中似乎没有窗口设置, 我想知道如何将 AppDelegate 的窗口类从 UIWindow 切换到其子类。
我经常做的就是在 application:didFinishLaunchingWithOptions: 中编写以下代码, 但每次都真的让我感到无趣。
UIViewController* vc = self.window.rootViewController;
self.window = [[MyWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.rootViewController = vc;
有什么想法吗?
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.
What I often do is writing the following codes in application:didFinishLaunchingWithOptions:,
but each time it really makes me dull.
UIViewController* vc = self.window.rootViewController;
self.window = [[MyWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.rootViewController = vc;
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你正在做正确的事。这就是自定义窗口的方法。如果你仔细想想的话,在 IB 中设置它也同样麻烦。
如果您对键入这三行代码感到迟钝,请考虑一下 Xcode 中代码片段库的便捷功能。
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.
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.