Swift 5: Unbalanced calls to begin/end appearance transitions for xxViewController when i try dismiss views

194 Views Asked by At

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)
0

There are 0 best solutions below