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.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
This question already has answers here:
Closed 6 years ago.
回答1:
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.
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.