Answer the question
In order to leave comments, you need to log in
Why is a view controller inactive after transitioning to it from another view controller through a navigation controller using custom animation transition?
There are 2 controllers (ViewController (starter) and SecondViewController (green)) and 1 navigation controller:
My project uses custom animation:
import UIKit
class TransitionManager: NSObject, UIViewControllerAnimatedTransitioning, UIViewControllerTransitioningDelegate {
func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval {
return 0.8
}
func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
var transform = CATransform3DIdentity
let container = transitionContext.containerView
guard let fromView = transitionContext.view(forKey: .from) else { return }
guard let toView = transitionContext.view(forKey: .to) else { return }
transform.m34 = -0.0019
container.layer.sublayerTransform = transform
container.insertSubview(toView, belowSubview: fromView)
fromView.layer.anchorPoint = CGPoint(x: 0.0, y: 0.5)
fromView.layer.position = CGPoint(x: 0, y: UIScreen.main.bounds.midY)
UIView.animate(withDuration: transitionDuration(using: transitionContext)) {
fromView.layer.transform = CATransform3DMakeRotation(-.pi/2, 0, 1.0, 0)
}
}
func animationController(forPresented presented: UIViewController, presenting: UIViewController, source: UIViewController) -> UIViewControllerAnimatedTransitioning? {
return self
}
}
class ViewController: UIViewController {
let transitionManager = TransitionManager()
override func viewDidLoad() {
super.viewDidLoad()
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3, execute: {
self.performSegue(withIdentifier: "segue", sender: self)
})
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
guard let navigationViewController = segue.destination as? UINavigationController else { return }
navigationViewController.transitioningDelegate = transitionManager
}
}
class SecondViewController: UIViewController, UIViewControllerTransitioningDelegate {
override func viewDidLoad() {
super.viewDidLoad()
print(view.isUserInteractionEnabled)
}
@IBAction func tapBtn(_ sender: UIButton) {
print("btn pressed") //не срабатывает. Почему?
}
}
print(view.isUserInteractionEnabled)
Answer the question
In order to leave comments, you need to log in
Perhaps in completion
your animation you still need to tell the system that the animation is complete.transitionContext.completeTransition(true)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question