简体   繁体   中英

Swift 3: UIViewControllerTransitioningDelegate stopped working

In my app I have a couple of classes used for custom transitioning. Prior to Swift 3 all was working fine. However, after updating to Swift 3, func presentationController(forPresented presented: UIViewController, presenting: UIViewController?, source: UIViewController) always has presenting as a nil. It's supposed to return the UIViewController that is initiating the transition. All was working perfectly with the previous Swift version. Am I missing anything?

I was stuck into this issue for over an hour, in swift 3.0 there has been changes in function signature convention, so that may be causing the issue as this changed fixed the issue at my end. As the protocol methods were optional so they were not getting called and no error was given.

func animationController(forPresented presented: UIViewController, presenting: UIViewController, source: UIViewController) -> UIViewControllerAnimatedTransitioning? {
    return ...
}

func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {
    return...
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM