Access container view child properties swift

后端 未结 4 1473
情书的邮戳
情书的邮戳 2021-02-12 04:20

What I want to achieve:

User presses the button in the ViewController then, the color of the button placed in the container view should change its color to red.

4条回答
  •  青春惊慌失措
    2021-02-12 04:39

    I recommend not to rely on segue.identifier, but rather test for destination type directly:

    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        super.prepare(for: segue, sender: sender)
    
        if let vc = segue.destination as? YourViewController {
            vc.someVariable = true
        }
    }
    

    This way you avoid mistakes with a misspelled segue name.

提交回复
热议问题