I've followed the instructions here and here which suggest that I should be able to create an unwind/edit segue even when using a storyboard reference.
The flow is quite simple:
PhotoDetailScene has a storyboard reference to EditHistoryScene and a tap gesture to trigger the segue, then I have a close button on EditHistoryScene that unwinds back to PhotoDetailScene. The present works fine (the custom 'show' segue opens the EditHistoryScene), and if I use a dismiss()
call it dismisses fine. But unwinding with the segue identifier always fails with:
EditHistoryScene has no segue with identifier 'UnwindEditHistorySegue'
In my EditHistoryScene close button action, I have:
func closeButtonPressed(_ sender: Any)
performSegue(withIdentifier: "UnwindEditHistorySegue", sender: self)
}
And in my PhotoDetailScene, I have added:
@IBAction func unwindToPhotoDetailScene(_ unwindSegue: UIStoryboardSegue) {
print("It works!")
}
And here's how I've set it up in IB, with the unwindToPhotoDetailScene()
method connected to the storyboard reference (since that's the only way IB would let me ctrl+link the outlet):
Unwind segue properties (and segue name)
Storyboard reference correctly set for destination storyboard:
Storyboard reference's exit point connected back to PhotoDetailScene:
EditHistoryScene storyboard instance appears to not be connected to the @IBOutlet?
My best guess is that it's failing because this is a storyboard reference, and the unwind segue is defined on the reference, not the actual storyboard instance. But I can't figure out how to attach the EditHistoryScene's exit point to the PhotoDetailScene directly.