为什么iOS 5.0不像普通窗口应用程序?为什么要求使用视图控制器? [英] Why doesn’t iOS 5.0 like plain window applications? Why does it request that view controllers be used?

查看:67
本文介绍了为什么iOS 5.0不像普通窗口应用程序?为什么要求使用视图控制器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个iOS应用程序,我创建与Xcode 4.0的基于窗口的应用程序模板。它工作正常时,那时,它使用的iOS 4.3 SDK。这是一个应用程序,只是将按钮,标签等直接放在窗口上。没有视图控制器 - 没有什么。

I have an iOS app that I created with Xcode 4.0’s "Window-based Application" template. It worked fine back then and it was using the iOS 4.3 SDK. This is an app that simply puts the buttons, labels, etc. directly onto a window. No view controllers—no nothing.

但现在我已经升级到Xcode 4.2(及其iOS 5.0 SDK),我运行应用程序,此消息被记录

But now that I’ve upgraded to Xcode 4.2 (and its iOS 5.0 SDK), and I run the app, this message gets logged to the console when the app launches in the simulator:

应用程序在应用程序启动结束时应该有一个根视图控制器

可以肯定的是,应用程序会继续工作,但是每次启动时都会打印出非常麻烦的日志。

To be sure, the app continues to work, but this rather bothersome log gets printed out on every launch.

为什么会发生这种情况?为什么iOS 5.0喜欢/请求视图控制器?

Why is this happening? Why does iOS 5.0 prefer/request view controllers?

推荐答案

我不知道为什么消息被记录, UIWindow和UIViewController在iOS的最近几次迭代中一直在增加。 iOS 4向UIWindow添加了一个 rootViewController 属性。这两个类一起工作来管理视图旋转。鉴于iOS 5向UIViewController引入的新功能(特别是创建您自己的容器视图控制器的能力),显然两个类之间的关系将继续发展。正如你所说,你的应用程序继续在iOS 5中运行,因此拥有一个根视图控制器不是一个困难和快速的要求。

I don't know specifically why the message is logged, but integration between UIWindow and UIViewController has been increasing over the last several iterations of iOS. iOS 4 added a rootViewController property to UIWindow. The two classes work together to manage view rotation. Given the new capabilities that iOS 5 introduced to UIViewController (specifically, the ability to create your own container view controllers), it's clear that the relationship between the two classes will continue to evolve. As you've said, your app continues to function in iOS 5, so having a root view controller isn't a hard and fast requirement yet. Perhaps there are features planned for future iOS versions that will depend on having a view controller available.


我没有任何反对他们的东西,如果iOS想要
我会使用它们。我只是好奇上述行为。

I don’t have anything against them, and I will use them if iOS wants me to. I was just curious about the above behavior.

我将解释记录的消息作为一个温和但持续的微软从苹果提供根视图控制器。大多数应用程序已经使用视图控制器,所以这不是一个大的变化,但可能有一些应用程序,没有正确设置窗口的 rootViewController 属性到他们的顶级视图控制器。

I'd interpret the logged message as a gentle but persistent nudge from Apple toward providing a root view controller. Most apps already use view controllers anyway, so this isn't a big change, but there are probably a number of apps out there that don't properly set the window's rootViewController property to their top-level view controller.

这篇关于为什么iOS 5.0不像普通窗口应用程序?为什么要求使用视图控制器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆