在模拟器中启动 iOS 应用程序时的白色视图
我已经在一个应用程序上工作了 4 个月,它相当复杂,但运行良好。 现在突然,我添加了一个新类,并对 MainWindow.xib 进行了一些更改,其中包含我的所有视图,现在当我使用模拟器启动它时,我只得到一个纯白色的视图。 我什至将其完全剥离,只剩下应用程序委托和一个带有按钮的简单普通视图。所以基本上我有一个应用程序,除了管理 tabBar 的 appDelegate 之外什么都没有,用一个简单的视图启动,没有框架什么也没有,我仍然得到一个白色的应用程序。
必须有一个选项我必须激活才能在模拟器中运行应用程序,但我无法弄清楚。
谢谢
I have been working for 4 months on an app, its pretty complex and works fine.
Now suddenly, I added a new class and did some changes to the MainWindow.xib with all my views there and now I just get a plain white view when I launch it with simulator.
I even stripped it down completely to nothing but the appdelegate and one simple plain view with a button. So basically I've got an app with nothing but an appDelegate managing a tabBar, launching with one simple view, no frameworks no nothing and I still get a white app.
There must be an option somewhere that I must have activated for the running of app in simulator but I can't figure it out.
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我意识到很久以前我从来没有解释过我是如何让它工作的:
正如 EmptyStack 指示的那样,窗口链接错误,但它不在代码中,而是在界面构建器的视图属性中。我已将窗口的类型设置为应该是窗口控制器的类,而不是类型(:
I realized I never explained how I got it working after all, long time ago:
Bad linking of the window, as EmptyStack directed me to, but it wasn't in the code, it was in the view properties in the Interface builder. I had set the Type of the window to be the class that should have been the controller of the window, not the type (:
如果您忘记通过
[self.window addSubview:yourRootViewController.view]
或通过self.window.rootViewController = yourRootViewController; 将根视图控制器添加到主窗口,就会发生这种情况。
(注意:如果您通过代码执行此操作)。而且,您看到白色是因为主窗口的
backgroundColor
是white
。This happens if you have forget to add the root view controller to the main window, either by
[self.window addSubview:yourRootViewController.view]
, or byself.window.rootViewController = yourRootViewController;
(Note: If you are doing it by code).And, you are seeing the white color because main window's
backgroundColor
iswhite
.