Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UINavigationControllerDelegate method call crash #64

Open
marcin-zbijowski opened this issue May 21, 2015 · 0 comments
Open

UINavigationControllerDelegate method call crash #64

marcin-zbijowski opened this issue May 21, 2015 · 0 comments

Comments

@marcin-zbijowski
Copy link

screen shot 2015-05-21 at 15 48 04
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant