A preliminary study on storyboard (i): Achieve simple page jump and return

Source: Internet
Author: User

PrefaceApple has been launching the story version for a long time and has not studied in depth. Recently, I want to try to use storyboard to do high-Fidelity Interactive app prototype, decided to learn under. Compared to the IB, storyboard almost no handwritten code, it can achieve page interaction, which is very suitable for xcode students to do rapid prototyping.
implement a simple page jumpNew project, select Single View application,xcode the generated project template will automatically use storyboard. Open the Main.storyboard file, as you can with IB, Drag the View object to the Viewcontroller's view. , simply add a page labeled Uilabel tag and a UIButton button:


Drag a Uiviewcontroller object to the main window as the second page, hold down the CTRL key, drag the button to connect the newly added page


Release the mouse and select action Segue in the list of pop-up black hover boxes: Modal so that after clicking the Orange button, page 2 will pop up from the bottom of page 1


Page 2 back to page 1, add a button on page 2, implement a Ibaction method with Uistoryboardsegue type parameter in the VIEWCONTROLLER.M file
-(Ibaction) Unwindsegue: (Uistoryboardsegue *) sender{    NSLog (@ "Unwindsegue%@", sender);}

Ctrl connect the button on page 2 to exit Viewcontroller, and associate Unwindsegue: Method




Operating effects in the simulator:

Code ImplementationPage 1 jump page 2: First clear the button line, and then CTRL line Viewcontroller to ViewController2, select the modal type

Check the connection between Viewcontroller and ViewController2, and set the identifier for the connection: 2VC2

Add code to the VIEWCONTROLLER.M and associate the button
-(Ibaction) PresentVC2: (ID) Sender {    NSLog (@ "Code implementation page Jump");    [Self performseguewithidentifier:@ "2VC2" Sender:sender];}
Page 2 back to Page 1, first clear the button line, and then add the Ibaction method in VIEWCONTROLLER2.M and associate the return button:
-(Ibaction) Backaction: (ID) Sender {    [self dismissviewcontrolleranimated:yes completion:nil];}



A preliminary study on storyboard (i): Achieve simple page jump and return

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.