简体   繁体   English

使用动画过渡时,UITabBar显示黑屏。 (迅速)

[英]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.

相关问题 UITabbar Tab更改动画在过渡时显示黑色故障 - UITabbar Tab change animation show black glitch at time of transition 为什么当我使用self.presentViewController(vc,动画:true,完成:nil)时黑屏Xcode swift 2 - Why am I getting a black screen when I use self.presentViewController(vc, animated: true, completion: nil) Xcode swift 2 过渡快速动画下的黑屏 - black screen under transition swift animation Swift——当移除 UIView(动画)时,它会停留在屏幕上 - Swift -- When removing UIView (animated) it stays on screen 屏幕加载时 AVPlayer 显示黑屏 - AVPLayer show black screen when screen load swift4中移动视图时屏幕为黑色 - screen is black when move view in swift4 快速选择到UITableViewController时黑屏 - Black screen when segueing to UITableViewController in swift iOS 11 Swift下的UITabBar过渡问题 - UITabBar Transition Issue Below iOS 11 Swift 从UINavigationController中解除具有自定义转换的UIViewController时出现黑屏 - Black screen when dismissing a UIViewController with custom transition from within a UINavigationController 在Swift UI中,当我使用NavigationLink时,屏幕上没有任何显示 - In Swift UI, nothing appears to show on the screen when I use NavigationLink
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM