Im trying to use unwind segue to go back from a controller where users have to select an option:
In the main controller, users can touch a button that direct them to a second view controller where I programmatically build up buttons (the options). when the users select one of the buttons, I want them to go back to the previous controller and pass the button data along.
I can't find a way to make the unwind segue work.
here is what I have in the second view controller:
// Tile touch handler function when button pressed
func selectedMood(sender:UIButton){
println("touching tile")
if(self.toShow == "mood"){
self.mood = moodAre[sender.tag - 1]
}
else{
self.action = actionAre[sender.tag - 1]
}
self.performSegueWithIdentifier("BackToPhraseSegue", sender: self)
}
@IBAction func prepareForUnwind(segue: UIStoryboardSegue) {
if (segue.identifier == "BackToPhraseSegue") {
let destination = (segue.destinationViewController as! PhraseController)
destination.mood = self.mood
destination.action = self.action
destination.place = self.place
}
}
// Data transmit between controller
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject!) {
if (segue.identifier == "BackToPhraseSegue") {
let destination = (segue.destinationViewController as! PhraseController)
destination.mood = self.mood
destination.action = self.action
destination.place = self.place
}
}
I linked the controller to the exit button (selecting the prepareForUnwind
func) in the storyboard and I gave an identifier to the unwindSegue "BackToPhraseSegue
"
What am I missing...