简体   繁体   中英

How to access child view controller(container view) in swift?

I have a view controller which has a child view controller. Now, I want to access childVC's labels and buttons from the view controller. How can I achieve that in swift?

I have tried this:

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

try this:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM