Reputation: 443
I have three View Controllers and want to go back from the third to the first on button click. I do the following:
doneButton.addTarget(self, action: #selector(ThirdViewController.doneButtonPressed(_:)), for: .touchUpInside)
@IBAction func unwindFromNewSubscription(segue: UIStoryboardSegue) {
}
@IBAction func doneButtonPressed(_ sender:UIButton!) {
print("DONE BUTTON PRESSED")
performSegue(withIdentifier: "changeFromNewToMain", sender: self)
}
And it works, BUT when I tap the button in V3 it instantly disappears and I see the animation: V2 slides down, so finally I can see the V1. But I want to animate the V3 to slide down instead of disappearing to see V1 after that. Any ideas how to fix that?
(V1, V2, V3 - View Controller 1, 2, 3)
Upvotes: 1
Views: 38
Reputation: 1797
Try to use presentingViewController?.dismiss(animated: true, completion: nil)
inside your @IBAction func doneButtonPressed(_ sender:UIButton!)
action instead of calling performSegue(withIdentifier: "changeFromNewToMain", sender: self)
.
Upvotes: 1