gpt4 book ai didi

ios - 尝试呈现 View Controller 时对开始/结束外观转换的不平衡调用

转载 作者:行者123 更新时间:2023-11-28 05:42:52 26 4
gpt4 key购买 nike

当我尝试呈现之前添加为子 Controller 的 View Controller 时,出现对开始/结束外观转换的不平衡调用错误,如何解决这个问题?

Unbalanced calls to begin/end appearance transitions

class VideoViewController: UIViewController {

}


class BigPlayerVC: UIViewController {
let videoVC = VideoViewController()

override func viewDidLoad() {
super.viewDidLoad()
addChild(videoVC)
view.addSubview(videoVC.view)
videoVC.view.translatesAutoresizingMaskIntoConstraints = false
// view.constrainViewEqual(videoReactController.playerView, top: 0, bottom: 0, left: 0, righta: 0)
videoVC.didMove(toParent: self)
}

@objc func onBTNClick() {
videoVC.willMove(toParent: nil)
videoVC.view.removeFromSuperview()
videoVC.view.translatesAutoresizingMaskIntoConstraints = true
videoVC.removeFromParent()
self.present(videoVC, animated: false, completion: nil)
}
}

最佳答案

我有一个临时解决方案:只需在 DispatchBlock 中延迟移动 present 方法如下所示:

DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.1) {
self.present(videoVC, animated: false, completion: nil)
}

关于ios - 尝试呈现 View Controller 时对开始/结束外观转换的不平衡调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55967189/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com