IBOutlet 链接到嵌入式容器视图控制器 [英] IBOutlet link to embedded container view controller

查看:32
本文介绍了IBOutlet 链接到嵌入式容器视图控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个复杂的 iPad 视图,我通过多个视图控制器来管理它.我以前(在 iOS6/Xcode 4.5 之前)通过在代码中分配我的视图控制器来做到这一点,并通过链接到主视图将各种视图连接到它们.

I have a complex iPad view that I manage by having several view controllers. I previously (before iOS6/Xcode 4.5) did this by allocating my view controllers in code, and hooked up the various views to them though links to the master view.

我想做的是使用新的 UIContainerView 容器视图将视图控制器嵌入故事板文件中.我似乎无法将嵌入式视图控制器的 IBOutlet 链接到主控制器.

What I would like to do is use the new UIContainerView container views to embed the view controllers in the storyboard file. I don't seem to be able to make an IBOutlet link to the embedded view controller to the master controller.

可以这样做吗?或者通过代码中的标签或其他东西检索嵌入式控制器?

Is it possible to do this? Or to retrieve the embedded controller via a tag or something in the code?

这个问题特别是关于使用容器视图

This question is SPECIFICALLY about using container views

推荐答案

我不确定检索嵌入式控制器"是什么意思.当您想使用控制器时,您可以使用 UIStoryboard 方法 instantiateViewControllerWithIdentifier:,使用您在 IB 中提供给控制器的标识符.您还可以使用 performSegueWithIdentifier:sender: 方法(它也实例化了视图控制器).您应该查看 Apple 文档中的在您的应用程序中使用视图控制器"部分.它还参考了子视图控制器与容器控制器同时实例化的事实.

I'm not sure what you mean by "retrieve the embedded controller". When you want to use a controller you use the UIStoryboard method instantiateViewControllerWithIdentifier:, using the identifier that you give to the controller in IB. You can also use the performSegueWithIdentifier:sender: method (which also instantiated the view controller). You should check out the "Using View Controllers in Your App" section in the Apple docs. It also makes reference to the fact that child view controllers are instantiated at the same time as the container controller.

编辑后:如果您在另一个视图控制器中嵌入一个容器视图,则可以使用 self.childViewControllers(这将是一个数组,因此如果只有一个,您可以从包含的控制器中引用该嵌入视图的控制器)与 lastObject).

After edit: If you embed a container view in another view controller, that embedded view's controller can be referenced from the containing controller with self.childViewControllers (which will be an array, so if there is just one, you can get it with lastObject).

这篇关于IBOutlet 链接到嵌入式容器视图控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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