简体   繁体   中英

Why is my unwind segue crashing my app?

I am trying to create an unwind segue that takes me back two viewControllers, and I thought I had everything set up correctly, but it crashes with no error printed when I perform the segue...

Here's what I've done:

In the DESTINATION viewController, we'll call it VC1 (bottom of the stack) I created this action:

@IBAction func unwind(segue:UIStoryboardSegue){}

In the interface builder I hooked up VC3 (the third view controller up) to the unwind segue via the exit button and named it "unwind".

I call perform for segue like so:

performSegue(withIdentifier: "unwind", sender: self)

Here is the view controllers and segue identifier

http://imgur.com/a/gJPYQ

The "Delete Trip" button calls the segue AFTER all the other logic has been taken care of.

As soon as that is called, my app crashes with no error message and shows me the AppDelegate screen. What's going on?

如果您推送了VC,则可以使用:

navigationController?.popToRootViewControllerAnimated(true)

If you have two VC's presented modally, then you will need to dismiss two VC's modally. Use: dismiss(..., completion: { dismiss(..., completion: nil)

Your current "unwind" segue is simply presenting the original one again..and maybe you don't have identifiers set up correctly or you are overlooking your view hierarchy.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM