Presenting a modal as a bottom sheet with a segue

93 Views Asked by At

I would like to present a detail view (VC2) as a modal over the bottom half of a parent view (VC1). I need to use a segue to enable a callback. I can see that a modal sheet can be presented in this way but can only find examples using UINavigationController such as in this example this example or without a segue this one.

Is there any way to achieve this functionality when I call VC2 from VC1 using a segue?

My code is:

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
    //handles segues and updates on return
    if segue.identifier == "showAddChangeGas" {//settings segue
        if let vc2 = segue.destination as? AddChangeGasViewController {
            vc2.gasIndex = gasIndex
            vc2.callback = {//sets callback to update parameters and fields from new settings
                self.gasTableView.reloadData()
                self.gasIndex = nil
            }
        }
    }
}
0

There are 0 best solutions below