Passing data with segue through navigationController

前端 未结 1 1228
长发绾君心
长发绾君心 2020-12-09 07:55

I\'m trying to push data from one viewController to another. I\'ve connected a viewController to another ViewController\'s navigationController and then set the identifier t

相关标签:
1条回答
  • 2020-12-09 08:08

    The destination view controller of the segue is the UINavigationController. You need to ask it for its top view controller to get to the real destination view controller:

    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        if segue.identifier == "showItemSegue" {
            let navController = segue.destination as! UINavigationController
            let detailController = navController.topViewController as! ShowItemViewController
            detailController.currentId = nextId!
        }
    }
    
    0 讨论(0)
提交回复
热议问题