iOS Foundation-uikit framework-Multi-controller management-modal

Source: Internet
Author: User
Tags uikit

Modal

Modal effect

First, modal demo (code)
1. Prior preparation
1> Create a new empty project, delete the default controller file
2> custom 2 controllers, set the Viewcontroller class to this class, respectively.
3> creates a window that sets its root controller to the first custom controller.
2. Drag a button to listen to the button and implement the method (to jump to the second interface)
-(Ibaction) jump{
Show a second controller interface
Mjtwocontroller *two = [[Mjtwoviewcontroller alloc] init];

[Self presentviewcontroller:two animated:yes completion:^{
You can do something at the end of the show.
}];
}
3. On the second controller view, drag a button to listen to this button and implement the method (used to return to the first
Interface
-(Ibaction) cancel{
[Self Dismissviewcontrolleranimated:yes completion:^{
You can do something at the end of the show.
}];
}

4. Process: When a click Jumps to the second controller view and the second view is fully displayed, the first view will
be removed (not destroyed). Similarly, when you click Cancel, the first view is put back, and then the slow
Slowly move the second view, and when the first view is fully displayed, the second controller and its view are destroyed

5. Improvement: Modal navigation Controller
1> adding a navigation bar to a controller the quickest way is to give it a deck of navigation controllers
-(Ibaction) jump{
Show a second controller interface
Mjtwocontroller *two = [[Mjtwoviewcontroller alloc] init];

Uinavigationcontroller *nav = [[Uinavigationcontroller alloc]
Initwithrootviewcontroller:two];
[Self presentviewcontroller:two animated:yes completion:^{
You can do something at the end of the show.
}];
}
2> Initializes an item in Viewdidload, which is used to cancel (return to the first view) and implement the
Method can be.
Self.navigationItem.leftBarButtonItem = [[Uibarbuttonitem alloc]
initwithtitle:@ "Cancel" Style:uibarbuttonitemstyledone target:self
Action: @selector (cancel)];

Second, modal demo (Storyboard)---Connection Select modal can be canceled by code

iOS Foundation-uikit framework-Multi-controller management-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.