iOS 根控制器
添加根控制器时这两种方法有什么区别:
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
并且:
[self.window addSubview:rootController.view];
[self.window makeKeyAndVisible];
干杯, 彼得
What is the difference between these two methods when adding a root controller:
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
And:
[self.window addSubview:rootController.view];
[self.window makeKeyAndVisible];
Cheers,
Peter
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
阅读文档后,似乎 rootViewController 属性是从 iOS SDK 4.0 开始的,而 addSubview 是从 iOS SDK 2.0 开始的。
我尝试过使用它们,它们似乎做完全相同的事情。所以我想如果你想支持 iDevices < 4.0 你应该使用 [
self.window addSubview:controller.view]
方法。After reading the documentation it seems that the rootViewController property is as of iOS SDK 4.0 and addSubview has been since iOS SDK 2.0.
I've tried using them both and they seem to do exactly the same thing. So I suppose if you want to support iDevices < 4.0 you should use the [
self.window addSubview:controller.view]
method.