Ios--storyboard use

Source: Internet
Author: User
Tags set background
First, Segue 1. IntroductionUsing storyboard can achieve jumps between multiple uiviewcontroller, the object that realizes jumps is Uistoryboardsegue object
Each uistoryboardsegue has three important attributes
1) Unique logo

@property (nullable,nonatomic, copy,readonly) NSString *identifier;
2) Source Uiviewcontroller

@property (nonatomic,readonly) __kindofuiviewcontroller *sourceviewcontroller;


3) Objective Uiviewcontroller

@property (nonatomic,readonly) __kindofuiviewcontroller *destinationviewcontroller;
2. The Segue type has the following types in storyboard (1) The push push type requires a Uinavigationcontroller object that must be pushed in the Uinavigationcontroller object Use when entering the next level of Uiviewcontroller
2 modal new scene will completely cover the old scene, and users can only interact with the new scene, can not interact with the old scene, unless the new scene can be closed
3 Custom Segue Type
4) popover (ipad only) 5 replace (ipad only)
3. Classification

In storyboard, segue is divided into automatic and manual type.

1) Automatic type

Drag two Uiviewcontroller in storyboard and set background to differentiate, drag a uibutton into the first uiviewcontroller to jump to the second Uiviewcontroller, as shown


Click UIButton and hold control to drag to the second Uiviewcontroller, appear as the picture, and select Modal (modal conversion)



After that, the selected segue type appears on the left side of the interface


You can set the identifier of segue to display it, generally in the segue of automatic type, you don't have to set identifier, you need to set it in manual type.



At this point, click UIButton, and you'll jump to the second uiviewcontroller.


2) Manual Type

Or, like the previous interface, drag into two Uiviewcontroller and set background to drag a UIButton into the first Uiviewcontroller

Select the first view controller and press control to connect to the second Uiviewcontroller, as shown



and select the Modal type

Manual type segue must be set up in several places

1 set Segue identifier, such as setting "Btnsegue" here

2) Add Action events to UIButton

-(Ibaction) Btnclick: (ID) Sender {
    
    NSLog (@ "%@", Nsstringfromselector (_cmd));
    
    Select the Segue object that implements the jump through the specified identifier, which is the segue that we wired in storyboard
    [self performseguewithidentifier:@ "Btnsegue" Sender:nil];
    
}


3) The method is called before the jump

-(void) Prepareforsegue: (Uistoryboardsegue *) Segue Sender: (ID) Sender {

    NSLog (@ "%@", Nsstringfromselector (_cmd)) ;

}

At this point, run the program click on the button, you can jump to the second Uiviewcontroller, and the console output the following information









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.