[英]UITabBar show black screen when use animated transition. (swift)
I'm making iOS UITabBar application and I try to using animate transition. 我正在制作iOS UITabBar应用程序,我尝试使用动画过渡。 But there is something wrong.
但是有些不对劲。 My app show black blank view when change view with animated transition.
当使用动画过渡更改视图时,我的应用程序显示黑色空白视图。
My some code 我的一些代码
class TransitionManager 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 的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! 现在我的第二个视图显示正确,但我的tabbar消失了! 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. PS。 sorry for my bad english.
对不起,我的英语不好。
If it only happens during the animation, try disabling the UITabBar translucency. 如果仅在动画期间发生,请尝试禁用UITabBar半透明效果。 I found similar behaviour with custom animations after updating my device to 9.0 and that ended up being the root problem for me.
在将设备更新到9.0后,我发现自定义动画的行为类似,最终成为我的根本问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.