Reputation: 716
I'm making iOS UITabBar application and I try to using animate transition. But there is something wrong. My app show black blank view when change view with animated transition.
My some code
class TransitionManager
...
func animateTransition(transitionContext: UIViewControllerContextTransitioning) {
let container = transitionContext.containerView()
let fromView = transitionContext.viewForKey(UITransitionContextFromViewKey)!
let toView = transitionContext.viewForKey(UITransitionContextToViewKey)!
let offScreenRight = CGAffineTransformMakeTranslation(container.frame.width, 0)
let offScreenLeft = CGAffineTransformMakeTranslation(-container.frame.width, 0)
toView.transform = offScreenRight
container.addSubview(toView)
container.addSubview(fromView)
let duration = self.transitionDuration(transitionContext)
UIView.animateWithDuration(duration, delay: 0.0, usingSpringWithDamping: 0.5, initialSpringVelocity: 0.8, options: nil, animations: {
fromView.transform = offScreenLeft
toView.transform = CGAffineTransformIdentity
}, completion: { finished in
transitionContext.completeTransition(true)
})
}
...
UITabBarController
func tabBarController(tabBarController: UITabBarController, animationControllerForTransitionFromViewController fromVC: UIViewController, toViewController toVC: UIViewController) -> UIViewControllerAnimatedTransitioning? {
var animatedTransitioningObject = TransitionManager()
return animatedTransitioningObject
}
I will try to add this code when transition complete
}, completion: { finished in
transitionContext.completeTransition(true)
// add this line
UIApplication.sharedApplication().keyWindow!.addSubview(toView)
})
Now my second view are show correctly, But my tabbar are disappear! I'm try to debug view hierarchy. It seem my tab bar isn't disappear. But It bring to back of second view.
How to fix this problem ?
ps. sorry for my bad english.
Upvotes: 3
Views: 1091
Reputation: 1613
If it only happens during the animation, try disabling the UITabBar translucency. I found similar behaviour with custom animations after updating my device to 9.0 and that ended up being the root problem for me.
Upvotes: 1