如何快速访问子视图控制器(容器视图)?

时间:2020-09-30 04:17:06

标签: swift xcode

我有一个带有子视图控制器的视图控制器。现在,我想从视图控制器访问childVC的标签和按钮。如何迅速实现目标?

我已经尝试过了:

var containerVc: UIViewController?
       override func prepare(for segue: UIStoryboardSegue,sender: Any?){
           if segue.identifier == "tosegue" {
               //...
            }
            
           }

1 个答案:

答案 0 :(得分:-1)

尝试一下:

var containerVc: YourContainerViewControllerClass?
       override func prepare(for segue: UIStoryboardSegue,sender: Any?){
           if segue.identifier == "tosegue" {
               containerViewController = segue.destinationViewController as? YourContainerViewControllerClass
            }
            
           }