Home > Article > Web Front-end > A preliminary study on StoryBoard (1): Implementing simple page jumps and returns_html/css_WEB-ITnose
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.
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);}
Simulation The running effect in the device:
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];}
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];}