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