I. Introduction to view switching types
In storyboard, segue has several different types. In iphone and ipad development, segue has different types.
In the iphone, segue has three different types: push, modal, and custom. The difference between these types lies in the way new pages appear.
In ipad, there are five different types: push, modal, popover, replace, and custom.
Modal Mode Conversion
The most common scenario is that the new scenario completely covers the old one. Users cannot interact with the previous scenario unless they disable it first.
It is the standard switching mode in viewController, including fading out or something. You can choose to switch the animation.
Modalview: A view is displayed. You can only operate on the view, but cannot switch to another view, unless you disable modalview.
The segue type corresponding to the Modal View is the modal segue.
* Modal: Transition to another scene for the purposes of completing a task. After the user completes the operation in the pop-up modalview, it should dismiss the modal view scene and switch back to the originalview.
Push
The Push type usually requires the first interface to be a Navigation Controller.
It is the method used to draw from the right when the lower level of the navigation View Controller
* Push: Create a chain of scenes where the user can move forward or back. the segue type is used with navigation viewcontrollers.
Popover (iPad only)
The popover TYPE Displays new pages in the form of floating windows.
* Popover (iPad only): Displays the scene in a pop-up "window" over top of the current view.
* Replace (iPad only ):
Replace the current scene,
Replace the current scene with another. This is used in some specialized iPad viewcontrollers (e.g. split-view controller ).
Custom
This is the custom jump method.
* Custom: Used for programming a customtransition between scenes.
Use custom segue type in Storyboard
I. Brief Introduction
Storyboard 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 Storyboard.
Ii. Use Storyboard
If you are creating a new project, the Xcode template can provide you with a configured Storyboard. For other applications, the Storyboard process is as follows:
1. Configure the Info. plist file of the application.
Add the UIMainStoryboardFile with the value of storyboard.
Delete the original NSMainNibFile
2. Create a storyboard file as before when creating an xib File
3. Configure viewController in storyboard
3. Create a Storyboard
You can use InterfaceBuilder to create a Stroyboard for your application. Generally, it is enough for an application to use a Storyboard. However, if you want to create more than one Storyboard, you can create it as long as you want. A Stroyboard should contain at least one ViewController.
On the iPhone, each ViewController on the Storyboard manages a scene, and each scene manages the screen stuff, but for the iPad, multiple scene can be displayed on one screen at the same time. You can drag viewController from the library to your Storyboard.
When you want to associate two viewcontrollers, you can press the control key and move the cursor from the button, table view cell... Drag and Drop to connect to another ViewController that you want to jump to. In this way, you create a segue and do not forget to set identifier.
4. data transmission between Scene
When you trigger a segger from the current scene, the system will automatically call the prepareforsegger: sender: method. If you want to transfer data when switching from one interface to another, you should override this method.
A --- "B
To transmit NSString A_data from AController to BController
@ Property: An NSString data
Then add the method to AController
-(Void) prepareForSegue :( UIStoryboardSegue *) segue sender :( id) sender
{
NSLog (@ "The segue id is % @", segue. identifier );
UIViewController * destination = segue. destinationViewController;
If ([destination respondsToSelector: @ selector (setData :)])
{
[Destination setValue: @ "this is the data to be passed" forKey: @ "data"];
}
}
Then, the data attribute in Bcontroller receives the data.
V. Redirect between viewcontrollers
1. If the current ViewController and the ViewController to be redirected exist in the Storyboard, You can execute javasmseguewithidentifier: sender: To achieve redirection.
2. If the target ViewController exists in the Storyboard, but there is no segue. You can use the instantiateViewControllerWithIdentifier method of the UIStoryboard to get it, and then use the method you want to achieve the jump, such as: Stack pressure.
3. If the target ViewController does not exist, create it.