在开发一个重负荷的UI应用程序时,QA团队报告说,我们的视图“翻转”停止正常工作。Aster测试我们注意到这个问题只针对IOS12。
如果您测试我添加的代码,即使对于只有背景色的两个视图的非常简单的示例,您也会在transitionWith中看到:正在显示的视图不是动画,只是被隐藏。隐藏的视图正在正确设置动画。
同样,这只是IOS12中的一个问题,在从:到:

class ViewController: UIViewController {

    var firstView: UIView!
    var secondView: UIView!
    var containerView: UIView!

    var showBackView = false

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.

        //containerView = UIView(frame: CGRect(x: 32, y: 32, width: 128, height: 128)) - // transitionFrom:To Code

        // General code
        firstView = UIView(frame: CGRect(x: 32, y: 32, width: 128, height: 128))
        secondView = UIView(frame: CGRect(x: 32, y: 32, width: 128, height: 128))

        firstView.backgroundColor = UIColor.red
        secondView.backgroundColor = UIColor.blue


        // transitionFrom:To Code
//        containerView.addSubview(firstView)
//        containerView.addSubview(secondView)
//        view.addSubview(containerView)


        // transitionWith: Code
        view.addSubview(firstView)
        view.addSubview(secondView)

        self.firstView.isHidden = false
        self.secondView.isHidden = true

        // General code
        let button = UIButton(frame: CGRect(x: 200, y: 200, width: 50, height: 50))
        button.addTarget(self, action: #selector(tappedButton), for: .touchUpInside)
        button.backgroundColor = UIColor.green
        view.addSubview(button)

    }

    @objc func tappedButton(sender: UIButton!) {
        flip()
    }

    func flip() {
        let transitionOptions: UIView.AnimationOptions = [.transitionFlipFromRight, .showHideTransitionViews]
        // transitionFrom:To Code
//        let toView = showBackView ? firstView : secondView
//        let fromView = showBackView ? secondView : firstView
//        UIView.transition(from: fromView!, to: toView!, duration: 1.0, options: transitionOptions, completion: nil)

        // transitionWith: Code
        print("******************")
        UIView.transition(with: firstView, duration: 3.0, options: transitionOptions, animations: {
            print(self.firstView.isHidden)
            print(self.secondView.isHidden)
            self.firstView.isHidden = !self.firstView.isHidden
        })

        print("----------------------")
        UIView.transition(with: secondView, duration: 3.0, options: transitionOptions, animations: {
            print(self.firstView.isHidden)
            print(self.secondView.isHidden)
            self.secondView.isHidden = !self.secondView.isHidden
        })
    }
}

这是已知的问题吗?我在网上找不到任何关于这个的参考资料;不幸的是,这打破了以前的动画。

最佳答案

我通过使用transitionFrom:To解决了这个问题,但这不是一个解决方案,而是一个解决方案。过渡带:仍然刹车在IOS12上!

10-08 05:22