self.window.rootViewController与窗口addSubview [英] self.window.rootViewController vs window addSubview

查看:285
本文介绍了self.window.rootViewController与窗口addSubview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在应用程序委托中注意到了很多iPhone应用程序的示例

I've noticed a lot of examples for iPhone apps in the Application Delegate

- (void)applicationDidFinishLaunching:(UIApplication *)application

[window addSubview: someController.view];(1)

相对于

self.window.rootViewController = self.someController;(2)

有没有实际的理由要使用一种方法呢?从技术上讲是正确的吗?控制器是否具有与数字(2)等效的命令,如

Is there any practical reason to use one over the other? Is one technically correct? Do controller's have an equivalent command to number (2) like

self.someController.rootController = self.someOtherController; // pseudocode

推荐答案

UIWindow rootViewController属性是iOS4的新增功能.

The UIWindow rootViewController property is new with iOS4.

较早的技术是使用addSubview.

推荐的新技术是设置rootViewController.

这篇关于self.window.rootViewController与窗口addSubview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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