iOS development-use segue to switch between storyboard

Source: Internet
Author: User

Using segue to switch back and forth between Viewcontroller, here's how to switch:

1. Switch using the Click button

Directly, in the View property interface that needs to be switched, click Modal and then pull to the previous view screen or button



2. Manually jump

If you pull the button on the Touchupinside, then click on the left button will be cut to the right view, assuming pull to the view, will connect manual, in the code to implement the jump


Set the Indentifier property of the segue:


To manually jump in the code:

Add trigger segue in Viewdidappear to make your own active jump-(void) Viewdidappear: (BOOL) animated{    [self performseguewithidentifier:@] Drawecg "Sender:self";}

Note: The viewdidload implementation of the jump is invalid


3. How to jump to a random page

Add the following code to the name of the function in the Viewcontroller file where it is possible to perform a superior jump:

#pragma mark defines this function, the other viewcontroller can jump right out of the exit-(Ibaction) GoHome: (Uistoryboardsegue *) segue{    [[Segue Sourceviewcontroller] class];}

Right-click on exit to jump to view, select the GoHome function, pull to the button you want to run, you can jump


The code implementation can also return to the previous page and log off the current page:

-(void) lastpage{    NSLog (@ "clicked on the previous View button");    [Self Dismissviewcontrolleranimated:yes completion:^ (void) {                //Code            }];}


This can also be achieved:

Get storyboard Uistoryboard *board = [Uistoryboard storyboardwithname:@ "Mainstoryboard" bundle:nil]; Get a view     uiviewcontroller *next = [Board instantiateviewcontrollerwithidentifier:@ "Second"] in the storyboard;//Jump     [ Self Presentmodalviewcontroller:next animated:yes];


Of course, assuming that you use the navigation Controller to connect using push, it is not the code above that jumps:

Jump to Landscapeviewcontroller

Open a horizontal screen interface-(ibaction) Openlandscapecontrol: (ID) Sender {    Landscapeviewcontroller *control = [[ Landscapeviewcontroller alloc]initwithnibname:@ "Landscapeviewcontroller" bundle:nil];        [Self.navigationcontroller Pushviewcontroller:control animated:yes];}
Use Pop to return to the previous view
Return to previous page-(ibaction) Clickback: (ID) Sender {    [Self.navigationcontroller poptorootviewcontrolleranimated:yes];}





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.