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 中的容器视图是什么?
基础教程推荐
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
