If I comment out the print line so much, everything in toVC does not load. Each ofVC element is zero. If I leave the expression to print, everything will work as intended. Why?
I use the method UITabBarControllerDelegate animationControllerForTransitionFromif this helps.
This has never happened before. As soon as I delete a line, it breaks the first time I touch any item attached to IBOutlet. Any help would be greatly appreciated.
func animateToProfile(using transitionContext: UIViewControllerContextTransitioning) {
guard let fromVC = transitionContext.viewController(forKey: .from)?.childViewControllers.first,
let toVC = transitionContext.viewController(forKey: .to)?.childViewControllers.first as? ProfileViewController,
let superviewToAdd = toVC.parent?.view else { return }
print("\(toVC.view.frame)")
let sideMenuOriginX = UIScreen.main.bounds.width * (98 / 414)
toVC.sideMenuView.frame.origin.x = toVC.view.frame.width
toVC.visualEffectView.alpha = 0
transitionContext.containerView.addSubview(superviewToAdd)
let duration = transitionDuration(using: transitionContext)
UIView.animate(withDuration: duration, delay: 0, options: [.curveEaseInOut], animations: {
toVC.sideMenuView.frame.origin.x = sideMenuOriginX
toVC.visualEffectView.alpha = 1
}, completion: { _ in
transitionContext.completeTransition(!transitionContext.transitionWasCancelled)
})
}
source
share