Swift pass data through navigation controller

后端 未结 8 2117
青春惊慌失措
青春惊慌失措 2020-12-12 18:13

One of my segues transitions from a view controller to a tableview controller. I want to pass an array between the two, but with a navigation controller before the tableview

8条回答
  •  一整个雨季
    2020-12-12 18:32

    Tommy's solution requires you to set up the Segue in Storyboard.

    Here is a code only solution:

    func functionToPassAsAction() {
        var controller: UINavigationController
        controller = self.storyboard?.instantiateViewControllerWithIdentifier("NavigationVCIdentifierFromStoryboard") as! UINavigationController 
        controller.yourTableViewArray = localArrayValue
        self.presentViewController(controller, animated: true, completion: nil)
    }
    

提交回复
热议问题