PresentViewController: How to Avoid overwriting the original viewController interface, uipageviewcontroller

Source: Internet
Author: User

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

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];




ToViewController. view. backgroundColor = [UIColor clearColor];

Navi. modalPresentationStyle = UIModalPresentationOverCurrentContext;

[Self presentViewController: navi animated: YES completion: nil];



As follows:

Related Article

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: 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.