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?
Thanks!

Hi,

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)
    setupDimmingView()
  }

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

Hi,
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!