Use UIPresentationController in ios8.

Source: Internet
Author: User

Use UIPresentationController in ios8.

1. Introduction to UIPresentationController

UIPresentationController is an API added to ios8. it is used to control Jump effects between controllers. For example, if you want to implement a special effect and display a window, the size and position are customized, And the mask is on the original page. Previously, you can operate some methods of view to implement it.

2. Introduction

1. Set the forwarding proxy and display method of the Target Controller

Controller. modalPresentationStyle = UIModalPresentationStyle. Custom // set the animation style controller. transitioningDelegate = transtinoDelegate // This object must implement the UIViewControllerTransitioningDelegate Protocol

2. transtionDelegate implements the UIViewControllerTransitioningDelegate protocol Method

// Return to the control controller. The animation object optional func animationControllerForPresentedController (presented: UIViewController, presentingController presenting: UIViewController, sourceController source: UIViewController) is displayed? // Returns the optional func animationControllerForDismissedController (dismissed: UIViewController)-> UIViewControllerAnimatedTransitioning? @ Availability (iOS, introduced = 8.0) // returns the optional func presentationControllerForPresentedViewController (presented: UIViewController, presentingViewController presenting: UIViewController !, SourceViewController source: UIViewController)-> UIPresentationController?

3. Control the jump class of the Controller

The class that controls controller redirection inherits from UIPresentationController

/* Constructor: parameter: the original controller */init (presentedViewController: UIViewController !, PresentingViewController: UIViewController !)

Common attributes and Methods
PresentedViewController: View Controller presentingViewController to be displayed by modal: View Controller containerView () Container view presentedView () func presentationTransitionWillBegin () Jump to func prepare (completed: Bool) jump to func dismissalTransitionWillBegin () dismiss: func dismissalTransitionDidEnd (completed: Bool) dismiss to complete func frameOfPresentedViewInContainerView () Target Controller settings

4. Control Animation

The control animation class inherits from UIViewControllerAnimatedTransitioning.

// Animation execution time func transitionDuration (transitionContext: UIViewControllerContextTransitioning)-> NSTimeInterval // func animateTransition (transitionContext: UIViewControllerContextTransitioning)

5. Summary

1. Set the forwarding proxy of the Target Controller

2. The session proxy returns three objects to control the transfer process.

3. Control the Controller transfer object. You can perform operations before and after the session, such as adding a mask.

4. Control the transfer animation, used to set the animation that the target controller appears or disappears, and the size and style of the controller.

3. API details

Wait...

4. Custom jump Demo

Wait...


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