Reputation: 582
I've created a typical unwind flow from my view controller #2 to back to view controller #1 using a programmatically created button using the segue to Exit technique.
I have trace statements that confirm that the button code is executing perfectly and that the #2 performSegueWithIdentifier func is being called with the correct segue ID, but nothing happens.
To clarify:
I've connect the view controller #2 to the Exit and confirmed the segue ID is exact in all places. I traced the #2 identifier in the #2 performSegueWithIdentifier func and it matches perfectly.
As I understand it, I no longer need to use the dispatch fix with the current version of 2016 XCode. I tried it anyway and nothing worked. There is no crash, just no unwinding.
Somehow the unwind technique isn't reversing using this Exit technique. Any ideas?
I've been following the tutorial here: https://spin.atomicobject.com/2014/12/01/program-ios-unwind-segue/
CODE VC #2:
// action func wired to button, fires perfectly
func unwind(seg:UIStoryboardSegue!) {
self.performSegueWithIdentifier("unwind", sender: self)
}
Upvotes: 1
Views: 3441
Reputation: 3661
unwind
function to VC1. Leave that implementation empty or perhaps put a print statement to see if its coming to that function.buttonAction:(button:UIButton)
that calls performSegueWithIdentifier("unwind"...)
in VC2.buttonAction
as the action for the button created programatically.Upvotes: 1
Reputation: 114846
In VC1 you need a function:
@IBAction func unwindToVC1(segue:UIStoryboardSegue) {
}
Then in your storyboard ctrl drag from the yellow view controller icon to the Exit icon and select unwindToVC1:
from the pop up
Give the unwind segue an identifier, say unwindToVC1
Now, in VC2, create your button touchUpInside
handler:
func buttonTapped(sender:UIButton) {
self.performSegueWithIdentifier("unwindToVC1")
}
when you set up your button programatically, add this method as the action handler:
button.addTarget(self, action: "buttonTapped:", forControlEvents: .TouchUpInside)
Upvotes: 1