Swift: prepareForSegue with two different segues

后端 未结 5 910
旧时难觅i
旧时难觅i 2021-01-04 19:29

I have 2 UIButtons on a view. Each of them are linked to 2 different views. They have to pass different data depending which button you just tapped.

I k

5条回答
  •  离开以前
    2021-01-04 19:46

    You could switch it...

    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
        if let identifier = segue.identifier {
            switch identifier {
            case "matchSegue":
                let controller = segue.destinationViewController as! ResultViewController
                controller.match = self.match
            case "historySegue":
                let controller = segue.destinationViewController as! HistoryViewController
                controller.history = self.history
            }
        }
    }
    

提交回复
热议问题