iOS 5 SDK 中的容器视图是什么?

What is Container View in iOS 5 SDK?(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 中的容器视图是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

AWS DynamoDB Batch Get Request - iOS(AWS DynamoDB 批量获取请求 - iOS)
Querying DynamoDB on non-key attributes(在非关键属性上查询 DynamoDB)
DynamoDB auto incremented ID amp; server time (iOS SDK)(DynamoDB 自动递增 ID amp;服务器时间(iOS SDK))
Where to find a clear explanation about swift alert (UIAlertController)?(哪里可以找到关于 swift alert (UIAlertController) 的清晰解释?)
Swift alert view with OK and Cancel: which button tapped?(带有 OK 和 Cancel 的 Swift 警报视图:点击了哪个按钮?)
Facebook Requests Dialog: Frictionless Requests in native iOS app possible?(Facebook 请求对话框:本机 iOS 应用程序中的无摩擦请求可能吗?)