I am currently trying to present a view controller using a UIPresentationController
. My issue is, when my custom transitioning delegate calls
func presentationControllerForPresentedViewController(presented: UIViewController, presentingViewController presenting: UIViewController!, sourceViewController source: UIViewController) -> UIPresentationController?
My presenting controller is nil
causing it throw an exception. I am presenting it from a view controller that is embedded in a navigation controller which is embedded in a tab bar controller. I have tried presenting it from these controllers as well to the same issue. It also works properly when there is not custom modal presentation but my goal is to customize it. I call it when a button is selected and the code is provided below. mapTransitionDelegate
is my custom transitioning delegate that I retain in a class property. Also, EnlargedMapViewController()
is initialized to have a custom modal presentation so that my transitioning delegate is called.
var enlargedMapController = EnlargedMapViewController();
enlargedMapController.transitioningDelegate = mapTransitionDelegate;
presentViewController(enlargedMapController, animated: true, completion: nil);
I would love to learn why this issue is occurring for future knowledge. As of now, my subclass UIPresentationController
is not even being initialized because of this exception.
EnlargedMapViewController
created in Interface Builder? If yes, it's a common trap. Use anIBOutlet
rather than create an instance programmatically. – Spiteful