获取对容器视图的视图控制器的引用 [英] Getting reference to view controller of the container view

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

问题描述

我有一个viewController,它包含一个ContainerView(正在设置一个ViewController)。我正在设置一个segue和prepareforsegue方法,我想获得一个嵌入在容器View中的viewController的引用。我怎么做。我知道使用segue.destinationViewController我们可以获得对UIViewController的引用,但我还想设置ContainerView指向的viewController。

I have a viewController which contains a ContainerView(which is setting up a ViewController). I am setting up a segue and in prepareforsegue method I want to get a reference to a viewController which is embedded in the container View. How do I do that. I know that using segue.destinationViewController we can get a reference to UIViewController but I want to also setup the viewController that is being pointed to by the ContainerView.

推荐答案

你已经有了答案。容器视图是视图,而不是视图控制器。它只定义了嵌入segue将子视图控制器的内容视图放入的框架。

You have your answer already. The container view is a view, not a view controller. It just defines the frame into which the embed segue will put the child view controller's content view.

当系统创建子VC时,它将调用prepareForSegue方法,并且此时,segue.destinationViewController将包含容器视图中包含的子视图控制器。

When the system creates the child VC, it will call your prepareForSegue method, and at that point, segue.destinationViewController will contain the child view controller that is contained in the container view.

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

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