-
Notifications
You must be signed in to change notification settings - Fork 98
Open
Description
Hi there!
In #4 you show how to use coordinators with tabBarController. But what if I want to go back from tabBarController? My code:
`
class TabCoordinator: BaseCoordinator {
let startNavigationController: UINavigationController
init(navigationController: UINavigationController) {
self.startNavigationController = navigationController
self.startNavigationController.navigationBar.isHidden = true
}
override func start()-> Observable<Void> {
let rootTabBarController = TabBarViewController.initFromStoryboard(name: "Main")
let viewControllers = initControllers()
let homeCoordinator = HomeCoordinator(rootViewController: viewControllers[0])
coordinate(to: COHomeCoordinator)
.subscribe()
.disposed(by: disposeBag)
let profileCoordinator = ProfileCoordinator(rootViewController: viewControllers[1])
coordinate(to: profileCoordinator)
.subscribe()
.disposed(by: disposeBag)
let logout = HomeCoordinator.logoutUser!
/*
In HomeCoordinator I have
let logoutUser: PublishSubject<Void>!
that bind to logout button.
*/
rootTabBarController.viewControllers = viewControllers
rootTabBarController.tabBar.isTranslucent = false
startNavigationController.pushViewController(rootTabBarController, animated: true)
return logout.do(onNext: {[weak self] _ in
self?.startNavigationController.popViewController(animated: true)
})
}
private func initControllers()->[UINavigationController]{
let homeVC = UINavigationController()
homeVC.tabBarItem = UITabBarItem(title: "Home", image: nil, selectedImage: nil)
let profileVC = UINavigationController()
profileVC.tabBarItem = UITabBarItem(title: "Profile", image: nil, selectedImage: nil)
return [homeVC, profileVC]
}
}
`
The problem is that I have growing memory when login-loguot few times. I have tried set coordinators to nil in return block, but it does not work.
Metadata
Metadata
Assignees
Labels
No labels