I'm working on an app that incorporates WYPopoverController and it works great in place where it should. I want to add custom animations between two controllers, instead of built in push / pop.
In navigation controller containing FROM and TO controllers I don't do anything related to the WYPopoverController, neither in controllers FROM and TO.
I've implemented navigation controller delegate, really simple and animator class that handles actual animation.
public class NavigationControllerDelegate: NSObject, UINavigationControllerDelegate {
let animator = Animator()
public func navigationController(navigationController: UINavigationController, animationControllerForOperation operation: UINavigationControllerOperation, fromViewController fromVC: UIViewController, toViewController toVC: UIViewController) -> UIViewControllerAnimatedTransitioning? {
if operation == UINavigationControllerOperation.Pop {
return self.animator
}
return nil
}
}
class Animator: NSObject, UIViewControllerAnimatedTransitioning {
public func transitionDuration(transitionContext: UIViewControllerContextTransitioning) -> NSTimeInterval {
return 0.33
}
public func animateTransition(transitionContext: UIViewControllerContextTransitioning) {
let toVC = transitionContext.viewControllerForKey(UITransitionContextToViewControllerKey)!
let fromVC = transitionContext.viewControllerForKey(UITransitionContextFromViewControllerKey)!
transitionContext.containerView().addSubview(toVC.view)
toVC.view.alpha = 0
UIView.animateWithDuration(self.transitionDuration(transitionContext), animations: { () -> Void in
fromVC.view.transform = CGAffineTransformMakeScale(0.1, 0.1)
toVC.view.alpha = 1
}) { (finished) -> Void in
fromVC.view.transform = CGAffineTransformIdentity
transitionContext.completeTransition(!transitionContext.transitionWasCancelled())
}
}
}
In the FROM controller I initialize navigation delegate
override public func viewDidLoad() {
super.viewDidLoad()
// ... some other code here
self.navigationController?.delegate = NavigationControllerDelegate()
}
Everything compiles and runs up until the point when I tap the (collection) cell and want to move to TO controller. At that point app crashes with error:
-[CALayer navigationController:animationControllerForOperation:fromViewController:toViewController:]: unrecognized selector sent to instance 0x7fc72e53e970
I've added a breakpoint and I end up inside sizzled_pushViewController:animated: method of UINavigationController. To be honest I have no idea how to approach the issue.
I'm working on an app that incorporates WYPopoverController and it works great in place where it should. I want to add custom animations between two controllers, instead of built in push / pop.
In navigation controller containing FROM and TO controllers I don't do anything related to the WYPopoverController, neither in controllers FROM and TO.
I've implemented navigation controller delegate, really simple and animator class that handles actual animation.
In the FROM controller I initialize navigation delegate
Everything compiles and runs up until the point when I tap the (collection) cell and want to move to TO controller. At that point app crashes with error:
I've added a breakpoint and I end up inside
sizzled_pushViewController:animated:
method of UINavigationController. To be honest I have no idea how to approach the issue.