I want a protocol to inherit from an Apple protocol UIViewControllerTransitioningDelegate
, add additional protocol requirements and provide a default implementation for some methods in that protocol. When I do that, the methods do not get called. When I implement the methods in the class itself, the methods do get called.
Here's what I'm talking about:
class FirstViewController: UIViewController, SlideDismissor {
let transition: PercentDrivenInteractiveTransitionWithState? = PercentDrivenInteractiveTransitionWithState()
}
protocol SlideDismissor: UIViewControllerTransitioningDelegate {
var transition: PercentDrivenInteractiveTransitionWithState? { get }
}
extension SlideDismissor {
func animationControllerForDismissedController(dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {
return nil // I do return something here, but for this example it isn't necessary
}
func interactionControllerForDismissal(animator: UIViewControllerAnimatedTransitioning) -> UIViewControllerInteractiveTransitioning? {
return transition
}
}
If I add the following code the functions do get called.
extension FirstViewController: UIViewControllerTransitioningDelegate {
func animationControllerForDismissedController(dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {
return nil // I do return something here, but for this example it isn't necessary
}
func interactionControllerForDismissal(animator: UIViewControllerAnimatedTransitioning) -> UIViewControllerInteractiveTransitioning? {
return transition
}
}
These methods I'm trying to provide a default implementation for are optional methods.