I have a Navigation Controller that contains 1 Parent VC and 1 Child VC. Data is passed between the two. On the Parent VC, I am passing data to the Child VC via prepareForSegue. On the Child VC back to Parent VC, I am passing data via a custom back button unwind segue.
Passing the data back and forth work great. However, I would like the Child VC to be able to be swiped right to close, while still passing the same information as in the unwind segue.
Is there a way to pass the data back to the parent using a swipe, along with being able to press the back button unwind? The only gesture method I am using is gestureRecognizerShouldBegin, which allows the Child VC to be swiped to the right.
extension ChildVC: UIGestureRecognizerDelegate {
func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
return true
}
}
For reference, here's my unwind:
@IBAction func unwindfromChild(_ sender: UIStoryboardSegue) {
if let CVC = sender.source as? ChildVC {
print("Unwind")
dataReceived() // do stuff with the received data
}
}
I solved this with a slightly different approach. I fully removed the unwind segue. Passing the data through delegation. The delegate method is called in navigationController:willShow
.