In my viewDidAppear, how do I know when it's being unwound by a child?

前端 未结 6 1308
一向
一向 2021-01-01 13:36

When my child performs an unwind segue, my controller\'s viewDidAppear gets called.

In this method (and this method alone, I need to know whether it was from an unwi

6条回答
  •  情话喂你
    2021-01-01 14:27

    Add method in your parent view controller

    @IBAction func unwindToParent(unwindSegue: UIStoryboardSegue) {
        if let childViewController = unwindSegue.sourceViewController as? ChildViewController {
            println("unwinding from child")
        }
    }
    

    As an exemple if the unwind segue is related to a button, in the storyboard link your button to it's view controller exit

    It will propose to link to unwindToParent method

    Then each time the unwind segue is performed, the unwindToParent method will be called

提交回复
热议问题