Swift 5:当我尝试关闭视图时,对 xxViewController 的开始/结束外观转换的调用不平衡
当我尝试关闭所有视图并转到主视图时,我有两个错误“对 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论