Storyboard in unwind segue use

Source: Internet
Author: User

The unwind segue can be used as a fallback in the navigation controller, with Push,modal, and popover three effects. (Effects and direct use of the navigation controller are the same, but more powerful).

Assuming that a is the root controller of the navigation controller, and the controller has another B controller, under B there is a C controller, the level can also be more deep, from the deepest controller back to a

The unwind segue can be reached directly, and only a method like the following code needs to be created in a:

?
1 2 3 - (IBAction)unwindToThisViewController:(UIStoryboardSegue *)unwindSegue {}

Here is an example of a specific implementation:

The controller that created the above structure in storyboard Navigationcontroller's root controller is the red controller, red to green, green to blue is the way to use push (other ways can also be used in a uniform way, Otherwise Xcode will print a warning:2014-05-20 15:30:13.165 unwindsegues[1027:70b] warning:attempt to dismiss from view Controller < Uinavigationcontroller:0x8a57320> while a presentation or dismiss are in)

Red Controller puts a button (Go green), connect green controller with push, add two buttons to green controller go blue, unwind to Red, go Blue direct connection Blue control, add two buttons in blue controller (go to Green, go to Red), add the method in the corresponding implementation code

?
1 2 3 4 -(IBAction)unwindToRed:(UIStoryboardSegue *)segue {     }

After writing the method, connect the button in the green controller to the lower exit of the green controller and select the method added in the Red Controller code

Add a similar method to the green controller's code again

?
1 2 3 4 -(IBAction)unwindToGreen:(UIStoryboardSegue *)segue {     }

Connect each of the two buttons in the blue controller as described above.

Test code:

Run the program directly click the button test effect, you can complete directly from the blue controller to the red controller jump.

This functionality is implemented through code:

    

View this unwind segue in the property view, so that the direct call can achieve the same effect, but only in their own class to use the segue, that is, there is no commonality

  

   [ self  Span class= "PLN" > Performseguewithidentifier  :@   " Unwindtoredsegueid "  sender  :  self  ; 


The wording of the article may not be accurate, if necessary, can be directly read the original English:
http://stackoverflow.com/questions/12561735/ What-are-unwind-segues-for-and-how-do-you-use-them

May 20, 2014

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.