material-motion-archive / transitions-objc

Archived February 16, 2017 :: Transitions for Apple Devices
Apache License 2.0
5 stars 1 forks source link

Create a TransitionController type #3

Closed jverkoey closed 8 years ago

jverkoey commented 8 years ago

Spec: https://material-motion.gitbooks.io/material-motion-starmap/content/specifications/transition_controller.html

This controller publicly conforms to UIViewControllerTransitioningDelegate.

Example use:

viewController.mdm_transitionController.directorClass = [PhotoDirector class];

Class prototype:

MDMTransitionController : NSObject <UIViewControllerTransitioningDelegate>

When mdm_transitionController is accessed, an instance of MDMTransitionController should lazily be created and then assigned to the view controller's transitioningDelegate (if one is not already set). This will allow us to hook in to the iOS view controller transitioning APIs.

jverkoey commented 8 years ago

🎊 My diff is ready for review at http://codereview.cc/D1259

jverkoey commented 8 years ago

From the discussion at http://codereview.cc/D1259:

Why'd we need to use associated objects?

Primarily because transitioningDelegate is a weak property. Because of this, somebody needs to hold a strong reference to the instance. There are many answers to "who should own this object?" and we've chosen one that appeared to balance convenience with expressivity.

Background

We want our transitionController to customize both the present and dismiss transitions. Using an associated object is a convenient way to ensure that our controller lives at least as long as the controller whose transitions it is customizing.

Some other ways that we'd considered building this API: