What is Container View in iOS 5 SDK?(iOS 5 SDK 中的容器视图是什么?)
问题描述
我很困惑为什么以及何时需要使用容器视图?我们如何通过代码实例化一个容器视图?
I'm confused that why and when we need to use the container view? and how can we instantiate a Container View by code?
推荐答案
容器视图是一种视图,您可以将其拖入您的情节提要中已有的视图控制器中(我们称之为 viewControllerA).你会自动获得一个通过嵌入转场连接到该视图的视图控制器.这个新的视图控制器有它的框架集,所以它与容器视图的大小相同——如果你调整容器视图的大小,控制器也会自动调整大小.因此,如果您愿意,可以将多个容器视图拖入 viewControllerA 中,每个视图控制器都有自己的视图控制器.在代码中,如果您需要访问这些嵌入式视图控制器,可以从 viewControllerA.childViewControllers 访问它们——这将为您提供您拥有的任何嵌入式视图控制器的数组.
The container view is a view that you can drag into one of your view controllers that you already have in your storyboard (we'll call this viewControllerA). You automatically get a view controller connected to this view via an embed segue. This new view controller has its frame set, so that it's the same size as the container view -- if you resize the container view, the controller will automatically resize as well. So, if you want, you can drag in multiple container views into viewControllerA, and each will have its own view controller. In code, if you need to access these embedded view controllers, they can be accessed from viewControllerA.childViewControllers -- that will give you an array of any embedded view controllers that you have.
在 WWDC 2012 Session Videos 视频中讨论了这些容器视图,名为在您的应用中采用 Storyboards".
There is a discussion of these container views in the WWDC 2012 Session Videos video called "Adopting Storyboards in Your App".
这篇关于iOS 5 SDK 中的容器视图是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:iOS 5 SDK 中的容器视图是什么?


基础教程推荐
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01