1

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)
akitainu22
  • 95
  • 1
  • 8
  • Is the problem caused by saying `setViewControllers` immediately followed by `dismiss`? In other words, if you omit one of those, does the problem go away? – matt Mar 07 '22 at 14:26
  • the problem keeps happening anyway, if I omit setViewControllers the errors are the same, but if I omit dismiss, the viewcontrollers doesn't close. – akitainu22 Mar 07 '22 at 14:31
  • I believe this has something to do with your view hierarchy. I tried the code with just a basic setup and it worked alright fine. Maybe you should explain a bit more on the navigation stack, for example Navigation controller has 3 VCs in its stack -> VC 3 presents VC4 -> Then I try to present VC5 from VC3 -> Then I run this code. Then we can try to recreate or might have better ideas to solve this. – Shawn Frank Mar 07 '22 at 16:49

0 Answers0