Home > Web Front-end > HTML Tutorial > A preliminary study on StoryBoard (1): Implementing simple page jumps and returns_html/css_WEB-ITnose

A preliminary study on StoryBoard (1): Implementing simple page jumps and returns_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 11:51:52
Original
1371 people have browsed it

Foreword

Apple has launched Storyboard for a long time, but I have never studied it in depth. I recently planned to try using StoryBoard to make a high-fidelity interactive app prototype, and decided to learn it. Compared with IB, StoryBoard can achieve page interaction with almost no handwritten code. This is very suitable for students who know Xcode to do rapid prototype development.


Achieve simple page jump

Create a new project and select Single View Application. StoryBoard will be automatically used in the project template generated by Xcode. Open Main.storyboard File, you can drag the view object to the ViewController's View like IB. As shown in the picture, simply add a page label UILabel label and a UIButton button:




to Drag a UIViewController object in the main window as the second page. Hold down the Ctrl key and drag the button to connect the newly added page




Release the mouse and select the Action Segue type in the pop-up black floating box list: Modal, so that after clicking the orange button, page 2 will pop up from the bottom of page 1




Page 2 Return to page 1, add a button on page 2, in the ViewController.m file Implement an IBAction method with UIStoryBoardSegue type parameters


- (IBAction)unwindSegue:(UIStoryboardSegue *)sender{    NSLog(@"unwindSegue %@", sender);}
Copy after login

Ctrl connect the button on page 2 to the Exit of ViewController, and associate the unwindSegue: method






Simulation The running effect in the device:



Code implementation

Page 1 Jump to page 2: Clear the button connection first , then Ctrl to connect ViewController to ViewController2, select Modal type



Select the connection between ViewController and ViewController2, and set the connection Identifier For: 2vc2



Add code in ViewController.m and associate the button

- (IBAction)presentVC2:(id)sender {    NSLog(@"代码实现页面跳转");    [self performSegueWithIdentifier:@"2vc2" sender:sender];}
Copy after login

Page 2 returns to page 1. First clear the button connection, then add the IBAction method in ViewController2.m and associate the return button:

- (IBAction)backAction:(id)sender {    [self dismissViewControllerAnimated:YES completion:nil];}
Copy after login



source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template