Swift 5:当我尝试关闭视图时,对 xxViewController 的开始/结束外观转换的调用不平衡

发布于 2025-01-12 15:34:04 字数 1105 浏览 2 评论 0原文

当我尝试关闭所有视图并转到主视图时,我有两个错误“对 DonesViewController 的开始/结束外观转换的不平衡调用”(它是我的最后一个视图控制器)和 BottomSheetViewController 的相同错误。 我在主视图控制器中有一个导航控制器,然后我使用了模态呈现。

这是我的代码:

viewModel.result
            .observe(on: MainScheduler.instance)
            .withUnretained(self)
            .subscribe(onNext: { owner, result in
                
                let vm = ResultViewModel(state: result)
                let vc = ResultViewController(with: vm)
                vc.modalPresentationStyle = .fullScreen
                owner.present(vc, animated: true)
                
                let rootViewController = owner.view.window?.rootViewController as? UINavigationController
                
                DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
                    rootViewController?.setViewControllers([rootViewController!.viewControllers.first!],
                    animated: false)
                    
                    rootViewController?.dismiss(animated: false, completion: nil)
                }
                
            }).disposed(by: disposeBag)

i have two errors "Unbalanced calls to begin/end appearance transitions for DonesViewController"(its my last viewcontroller) and the same error fot BottomSheetViewController, when i try to dismiss all views and go to main view.
I have a navigation controller in the main viewcontroller, and then i used modal presented.

This is my code:

viewModel.result
            .observe(on: MainScheduler.instance)
            .withUnretained(self)
            .subscribe(onNext: { owner, result in
                
                let vm = ResultViewModel(state: result)
                let vc = ResultViewController(with: vm)
                vc.modalPresentationStyle = .fullScreen
                owner.present(vc, animated: true)
                
                let rootViewController = owner.view.window?.rootViewController as? UINavigationController
                
                DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
                    rootViewController?.setViewControllers([rootViewController!.viewControllers.first!],
                    animated: false)
                    
                    rootViewController?.dismiss(animated: false, completion: nil)
                }
                
            }).disposed(by: disposeBag)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文