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