iOS Learning--the principle and implementation of navigation 2 modal

Source: Internet
Author: User

What is modal?

This is a question, what is modal? Simply put, you are traveling, suddenly the boss to call you to solve technical problems, very urgent. So you have to take care of the phone before you can travel.

Or you want to watch the video, the website pops up the following window, you must install the software to continue to see ...


So modal, is a state, you have to solve this state before you can continue.

Realizing modal
in iOS, the modal app can be click on the registration page, then register to finish back to the original page
Getting objects from Storyboard
Storyboardid is defined as follows:
An    identifier string, uniquely identifies the view controller in the storyboard file. You set the identifier for a given view controller in Interface Builder when configuring the storyboard file. This identifier are not a property of the view controller object itself and are used only by the storyboard file to locate T He view Controller.
:

translation: This flag string is the unique identifier of the storyboard that is trying to control the controller. You can set this identifier in the storyboard, which is not a property of the view controller, but is only used when reading the view controller in the story version.

Thatis, Storyboardid is used to get and build Viewcontroller objects in storyboard

Get Storyboard Object
    Gets the Storyboard object    uistoryboard *mainstoryboard=[uistoryboard storyboardwithname:@ "Main" bundle:nil];    Create Uiviewcontroller objects with storyboard ID    uiviewcontroller* Model=[mainstoryboard instantiateviewcontrollerwithidentifier:@ "Modelviewcontroller"];

First function: Storyboardwithname:bundle: try a specific string, create and return the Storyboard object: The returned object is Main.storyboard


Second function: Create an instance of Viewcontroller with the specified identifier, identified as: Storyboardid, set on the property page
Convert animation type

Next, set the conversion animation type: (transition: Excessive)

Excessive animation    Model.modaltransitionstyle=uimodaltransitionstylepartialcurl;

There are four types of options available:

typedef ns_enum (Nsinteger, Uimodaltransitionstyle) {    uimodaltransitionstylecoververtical = 0,    Uimodaltransitionstylefliphorizontal,    Uimodaltransitionstylecrossdissolve,    Uimodaltransitionstylepartialcurl Ns_enum_available_ios (3_2),};
Let's explain this article by clause:

1 cover: including, covering Vertical: Vertical translation comes up--vertical overlay

2 Flip: Throw, pop horizontal: Horizontal translation comes up-horizontal throw, (this good bold ... )

3 Cross: Crossover dissolve: Dissolve translates to--cross-dissolve (about vaguely revealing, gradually apparent)

4 Partial: Local curl: Curly translate Chinese--Lift a corner (your own brain)

Open and close the modal
1 Open the modal code as follows:
    [Self Presentviewcontroller:model animated:yes completion:^{        NSLog (@ "Open modal, just so Simple");    }];

This function is defined in the Uiviewcontroller class: The meaning is to use a controller as its own mode, the following parameters are a block, the inside of the code with the execution of the function, interested students can search their own
2 Close the modal code as follows
-(Ibaction) Closemodel: (ID) Sender {    [self dismissviewcontrolleranimated:yes completion:^{        NSLog (@ "modal End");}    ];}

This function is also defined in the Uiviewcontroller class, meaning to end itself as the controller's modal state, returning the original controller
:

Related code
https://git.oschina.net/zhengaoxing/navigation
Welcome ReprintThis address: http://blog.csdn.net/zhenggaoxing/article/details/43269109
Previous article:

iOS Learning--Navigation 1 overview

iOS Learning Series Catalog:
iOS Learning Series Catalog--Occasional updates













iOS Learning--the principle and implementation of navigation 2 modal

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.