PresentViewController: How to Avoid overwriting the original viewController interface, uipageviewcontroller
How does PresentViewController not block the original viewController interface?
Sometimes, you may need to bring up a View with relatively independent functions to implement some functions, but you do not want to simply add a View and want to make it the form of viewController. This article describes how to implement presentViewController without overwriting the original view.
For specific source code, visit http://www.cnblogs.com/sely-ios/p/4552134.html
The bottom jump mechanism between uiviewcontrollers is not described in detail. However, Apple provides a Delegate for redirect between custom uiviewcontrollers, that is, UIViewControllerTransitioningDelegate, for details, refer to the introduction of this Protocol in XCode.
Before iOS7, You need to customize UIViewControllerTransitioningDelegate and UIViewControllerAnimatedTransitioning to meet our needs. After ios8. Apple has provided a solution, you only need to set the modalPresentationStyle attribute of UIViewController to UIModalPresentationOverCurrentContext to easily meet our requirements.
How to implement it?
Here I also refer to the Demo samples contributed by Blanche Faur on github.
-(IBAction) presentViewController :( id) sender
{
If (self. background)
{
[Self. view bringSubviewToFront: self. background];
Self. background. hidden = NO;
Self. background. layer. opacity = 0.3;
}
UINavigationController * navi = [self. storyboard instantiateViewControllerWithIdentifier: @ "ToViewControllerNavi"];
ToViewController * toViewController = navi. viewControllers [0];
[ToViewController setHandler: ^ (){
Self. background. hidden = YES;
}];
If ([[[UIDevice currentDevice] systemVersion] floatValue] <8.0)
{
[Navi setTransitioningDelegate: self. transDelegate];
Navi. modalPresentationStyle = UIModalPresentationCustom;
[Self presentViewController: navi animated: YES completion: nil];
}
Else
{
ToViewController. view. backgroundColor = [UIColor clearColor];
Navi. modalPresentationStyle = UIModalPresentationOverCurrentContext;
[Self presentViewController: navi animated: YES completion: nil];
}
}
As follows: