IOS development-UI (10) StoryBoard,-uistoryboard

Source: Internet
Author: User
Tags notification center

IOS development-UI (10) StoryBoard,-uistoryboard

This is the last part of the UI.

Knowledge Point

1. Introduction to UIStoryBoard

2. UIStoryBoard page Jump

3. Transfer value between UIStoryBoard Interfaces

======================================

UIStoryBoard Introduction

UIStoryBoard is a new method that you can use to define user interfaces, such as xib. Unlike xib, it can manage multiple viewcontrollers at the same time and configure the jump relationship between viewcontrollers in the UIStoryBoard. If only one view controller in the main window is used as the first interface of the UIStoryBoard, check Initial Scene. UIStoryBoard integrates all the xib files in the original project and establishes the jump relationship between the two viewcontrollers by dragging, so that the UI jump logic of the entire program is clear. After UIStoryBoard is used, fewer code will be written on the interface.

 

1. If only one view controller in the main window is used as the first interface of the story board, check Initial Scene.

Select the current scene of is initial view controller to enter the first scene of the application.

 

2. In the UIStoryBoard, you can customize the cell on the UITableView directly.

 

======================================

UIStoryBoard page Jump

3. Note the difference between push and present.

1). push corresponds to pop and present corresponds to dismiss;

2). The present can only be returned step by step. push all views is controlled by the view stack. You can return to the upper level, or to the root vc and other vc.

3). present is generally used for switching between different business interfaces. push is generally used for switching between different interfaces of the same business.

4. How to jump to an unconnected Controller

1) + (UIStoryboard *) storyboardWithName :( NSString *) name bundle :( NSBundle *) storyboardBundleOrNil;

Purpose: obtain a UIStoryboard object.

 

2)-(id) instantiateViewControllerWithIdentifier :( NSString *) identifier

Purpose: obtain a controller with the identifier ID in the UIStoryboard file. // jump to the unconnected controller.

// Obtain Main. storyBoardUIStoryboard * storyBoard = [UIStoryboard storyboardWithName: @ "Main" bundle: nil]; // obtain the corresponding controller object UIViewController * ctl = [storyBoard identifier: @ "ctlC"] Through StoryBoardID; // jump to [self. navigationController pushViewController: ctl animated: YES];

 

 

 

6. How to return to the previous interface

 

To implement a method in the upper-level view controller, the following format must be met:

-(IBAction) + any method name + (UIStoryboardSegue *) + any variable name

// Method of returning UIStoryBoard connections-(IBAction) unwindingSegue :( UIStoryboardSegue *) segue {NSLog (@ "sourceViewController =%@ destinationViewController =%@", segue. sourceViewController, segue. destinationViewController); // role: it will be applied to the reverse value transfer

 

 

 

======================================

Value Transfer Between UIStoryBoard Interfaces

 

1. forward data transfer

-(Void) prepareForSegue :( UIStoryboardSegue *) segue sender :( id) sender

Function: called when the scenario is to be switched

// When switching the interface (push, present), the following method is called-(void) prepareForSegue :( UIStoryboardSegue *) segue sender :( id) sender {// forward pass value if ([segue. identifier isinclutostring: @ "login"]) {LoginViewController * ctl = segue. destinationViewController; // assign a value to ctl. userNameStr = self. userNameTF. text; ctl. passwordStr = self. passWordTF. text ;}

 

 

 

2. Reverse value transfer (traditional block, protocol proxy, notification center, and single-case value transfer still work)

-(IBAction) unwind :( UIStoryboardSegue *) segue

Function: called when the previous scenario is returned

 

// Method of the UIStoryBoard connection method // you can connect to the UIStoryBoard using the method of redirection first.-(IBAction) unwindingSegue: (UIStoryboardSegue *) segue {// value transfer in reverse mode (dedicated to UIStoryBoard) // determine whether to click if the registration is complete. identifier isEqualToString: @ "finish"]) {// rigorous if ([segue. sourceViewController isKindOfClass: [RegisterViewController class]) {RegisterViewController * ctl = segue. sourceViewController; // refresh the UI self. userNameTF. text = ctl. userNameTF. text; self. passWordTF. text = ctl. passWordTF. text; // function: it will be applied to the reverse value transfer }}

 

Related Article

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.