Several segue differences in storyboard and view switching: Push,modal,popover,replace and Custom

Source: Internet
Author: User

First, the view switch type introduction
There are several different types of segue in storyboard, and the type of segue is different in the development of iphone and ipad.
In the iphone, Segue has: Push,modal, and custom three different types, these types of differences in the way that appear with new pages.
In the ipad, there are five different types of push,modal,popover,replace and custom.

Modal modal conversion
The most commonly used scene, the new scene completely covers the old one. Users can no longer interact with the previous scene unless they close the scene first.
is the standard toggle in Viewcontroller, including fading out what, you can choose to toggle the animation.
Modalview: It will pop up a view, you can only operate on the view, and cannot switch to other view, unless you close the Modalview.
The Modal view corresponds to the segue type that is Modal segue.
*modal:transition to another scenes for the purposes of completing a task. When user is done in the pop-up Modalview, the dismiss view should be Modal Scene and then switch back to the Originalview.

Push

The push type generally requires the first interface to be a navigation controller.

Is the kind of way to use the right-hand side of the navigation View controller in the lower level.
*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)

PopOver type, is to use the form of floating window to display the new page
*popover (IPad only):D isplays the scene in a pop-up "windows" over top of the current view.

Replace

*replace (IPad only): Replaces the current scene,replace the present scene with another. This was used in some specialized iPad viewcontrollers (e.g. Split-view Controller).

Custom

*custom: is the custom jump mode. Used for programming a customtransition between scenes.

Using the custom Segue type in storyboard

First, brief

Storyboard is a new way that you can use to define the user interface, like Xib.
Unlike Xib, it can manage multiple viewcontroller at the same time, and you can configure a jump relationship between Viewcontroller in storyboard.

Second, the use of storyboard
If you are creating a new project, Xcode templates can provide a configured storyboard for you to use. For other applications, the process of using storyboard is as follows:
1. Configuring the Application Info.plist file
Add Uimainstoryboardfile, with a value of storyboard file name.
Delete the original nsmainnibfile
2. Create a storyboard file just like the previous Xib file
3, configuration storyboard in the Viewcontroller

Third, the creation of storyboard
You can use Interfacebuilder to create a stroyboard for your application, which is generally enough for an app to use a storyboard, but if you want to create more than one, you can, if you like. A stroyboard should contain at least one viewcontroller.
In the iphone, for every viewcontroller in storyboard, a scene is managed, and each scene manages the stuff on screen, but for the ipad, multiple scenes can be present on a screen at the same time. You can drag and drop Viewcontroller from the library to your storyboard.
When you want to associate two Viewcontroller, you can press the control key, with the mouse from a viewcontroller in the button,table view cell ... Drag and drop connect to another viewcontroller you want to jump to, so create a segue, don't forget to set identifier OH.

Iv. data transfer between scene
When you trigger a segue from the current scene, the system automatically calls Prepareforsegue:sender: This method. If you want to transfer data from one interface to another, you should override this method.
A---"B
Want to transfer data NSString A_data from Acontroller to Bcontroller, then in Bcontroller
@property a NSString data
Then add the method in the 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 transmitted" forkey:@ "" "];
}
}
After that, the Data property in the Bcontroller is received. 


V. Jumps between the Viewcontroller
1. If the segue exists between the current Viewcontroller in storyboard and the Viewcontroller to jump, you can perform performseguewithidentifier:sender: This method implements jumps.
2, if the target Viewcontroller exists in storyboard, but there is no segue. You can go through Uistoryboard's Instantiateviewcontrollerwithidentifier: This method gets to it, and then uses the way you want to implement the jump, such as: press stack.
3, if the target viewcontroller does not exist, then go to create it.

Several segue differences in storyboard and view switching: Push,modal,popover,replace and Custom

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.