ios--Summary Series Eight (continue)

Source: Internet
Author: User

First, what is Segue

(1) Each line on the storyboard for the interface jump, is a Uistoryboardsegue object (abbreviation Segue)

Second, the Segue property

(1) Each of the Segue objects has 3 properties

1) Unique identification

@property (nonatomic, readonly) NSString *identifier;

2) Source Controller

@property (nonatomic, readonly) ID Sourceviewcontroller;

3) Target Controller

@property (nonatomic, readonly) ID Destinationviewcontroller;

Iii. Types of Segue

(1) According to the Segue execution (jump) moment, segue can be divided into 2 major types

1) Automatic type: After clicking on a control (such as a button), automatically executes the segue, automatically completes the interface jump

2) Manual type: Need to write code manually to perform segue to complete the interface jump

(2) Automatic type Segue

1) Control-Drag the line directly from the control to the target controller

2) Click "Login" button, will automatically jump to the right controller

3) If you click on a control, do not need to make any judgment, be sure to jump to the next interface, it is recommended to use "Automatic type Segue"

(2) Manual type Segue

1) Control-Drag the line from the source controller to the target controller

2) manual type segue need to set an identity (e.g.)

3) At the right moment, use the Perform method to perform the corresponding segue

[Self performseguewithidentifier:@ "login2contacts" sender:nil];

The segue must be executed by the source controller, which means that the perform method must be called by the source controller

If you click on a control, you need to make some judgments, that is to say: to meet certain conditions before jumping to the next interface, it is recommended to use "manual type Segue"

(3) Performseguewithidentifier:sender:

1) Use Performseguewithidentifier: Method can execute a segue, complete interface jump

2) Next study Performseguewithidentifier:sender: The complete execution of the method

[Self performseguewithidentifier:@ "login2contacts" sender:nil];

This self is the source controller.

(4) According to identifier to find the corresponding line in the storyboard, new Uistoryboardsegue object

1) Set the Sourceviewcontroller of the Segue object (source Controller)

2) New and set the Destinationviewcontroller (target controller) of the Segue object

(5) Call Sourceviewcontroller The following method, do some pre-jump preparation and pass in the creation of a good Segue object

-(void) Prepareforsegue: (Uistoryboardsegue *) Segue Sender: (ID) sender;

This sender was the sender of the Performseguewithidentifier:sender:

(6) Call the-(void) Perform of the Segue object; method starts to perform the interface jump operation

1) Get the Uinavigationcontroller where Sourceviewcontroller is located

2) Call Uinavigationcontroller's Push method to press the Destinationviewcontroller into the stack to complete the jump

(7) Transfer of sender parameters

Iv. data transfer of the Controller

(1) The data transmission between the controller is mainly 2 kinds of cases: shun and reverse transmission

1) Shun Chuan

Direction of the controller jump: Aàc

Direction of data transfer: Aàc

Data transfer method: In a Prepareforsegue:sender: method according to segue parameters obtained Destinationviewcontroller, that is, controller C, directly to the Controller C pass data

(To get the data in C's Viewdidload method, assign a value to the UI control on the interface)

Reverse transmission

Direction of the controller jump: Aàc

Direction of data transfer: Càa

How to pass the data: Let a become the agent of C, call a proxy method in C, pass the data through the parameters of the proxy method to

Wu, Uitabbarcontroller

(1) Similar to Uinavigationcontroller, Uitabbarcontroller can also easily manage multiple controllers, easily switch between the controller, the typical example is QQ, and other applications

ios--Summary Series Eight (continue)

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.