UIPresentationController Tutorial: Getting Started | raywenderlich.com

Learn how to build custom view controller transitions and presentations with this UIPresentationController tutorial.

This is a companion discussion topic for the original entry at https://www.raywenderlich.com/3636807-uipresentationcontroller-tutorial-getting-started

On the Setting Up the Dimming View section, the instruction reads to add a call to setupDimmingView() at the end of init(presentedViewController:presenting:direction:). However, it is not clear where exactly to put it.
If I put setupDimmingView() right below self.direction = direction, I get a “use of unresolved identifier” error (Xcode doesn’t know it).
Where exactly are we supposed to include that call?


setupDimmingView() should be placed after the call to super.init(presentedViewController: presenting)

At the end of the tutorial, the init method should look like this:

init(presentedViewController: UIViewController,
       presenting presentingViewController: UIViewController?,
       direction: PresentationDirection) {
    self.direction = direction
    super.init(presentedViewController: presentedViewController, presenting: presentingViewController)

Can I use the functionality you’ve discussed here, but when I’m using a container view (full screen) inside a ‘RootViewController’… i.e. I have a menu system that consists of a RootViewController, that has a full screen ‘container’ view, and new ViewControllers.view is added to the subview of this container view, and the new ViewControllers is added as a childViewController on the RootViewController object.

How do I handle custom transitions and animations when using container views and childViewControllers?

@ron.kliffer Can you please help with this when you get a chance? Thank you - much appreciated! :]

Hi Ron. I think in alongsideTransition scope reference to self must be weak

When adding child view controllers you need to manipulate the view positions on your own using one of the available UIKit animation APIs

There is no reference cycle created in this case, so there’s no need for self to be weak

Hi, how do the presentation controller and the animation controller have access to the PresentationDirection enum declared within the scope of SlideInPresentationManager? Is the fact that they are being initialised within that class sufficient for that, even though their classes are defined in separate files?

PresentationDirection gets the default access level internal.
This means it is Visible from anywhere in the same module or app.

For more on access control you can check out the official Swift documentation

This tutorial is more than six months old so questions are no longer supported at the moment for it. Thank you!