Apple's view controller programming guide states (emphasis added):
The view controller that calls the presentViewController:animated:completion: method may not be the one that actually performs the modal presentation. The presentation style determines how that view controller is to be presented, including the characteristics required of the presenting view controller. For example, a full-screen presentation must be initiated by a full-screen view controller. If the current presenting view controller is not suitable, UIKit walks the view controller hierarchy until it finds one that is. Upon completion of a modal presentation, UIKit updates the presentingViewController and presentedViewController properties of the affected view controllers.
I am attempting to implement a custom view controller presentation with a UIPresentationController subclass. When I present my view controller:
let sb = UIStoryboard.init(name:"Main", bundle:nil)
let presented = sb.instantiateViewController(withIdentifier:"PresentedTableViewController")
presented.transitioningDelegate = overlayTransitioningDelegate
presented.modalPresentationStyle = .custom
definesPresentationContext = true
present(presented, animated:true, completion:nil)
...the presentingViewController
property refers to a view controller higher up the hierarchy than the one that initiated the presentation. This says to me that I have not satisfied whatever mysterious requirements that UIModalPresentationStyle.custom
desires of its presenting view controller, and so it went looking elsewhere.
The thing is, I can't find these requirements documented anywhere, nor can I figure them out. I need a reference to the initiating view controller in my presentation controller. And, okay, I could sidestep the issue entirely by providing the reference myself, but I'd prefer to do things the right way rather than code around my ignorant mistakes.
Does anyone know what must be done for a view controller to qualify as a presenting view controller when using UIModalPresentationStyle.custom
? Thanks!