简体   繁体   中英

Unwinding Modal Segue before Root Navigation Controller - iOS

Here are my View Controllers:

在此处输入图片说明

There is a modal segue between the initial view controller and the root of the navigation controller.

As you can see the Tab Views are sharing the 'Back' Button.

This is done through the navigation controller.

When I run the following command:

    self.dismissViewControllerAnimated(true, completion: nil)

when 'Back' is clicked, nothing happens.

I believe this brings you back to the root of the Navigation Controller, which essentially does nothing.

So how do I make the 'Back' button bring me back to first, initial View Controller.

Thanks !

Unwind by using an unwind segue.

Place this in your initial ViewController:

@IBAction func unwindToSegue (segue : UIStoryboardSegue) {}

And then ctrl-drag from your button to the "Exit" symbol of your TabViewController. The method unwindToSegue should show up, so pick it.

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