मैं एमवीवीएम-सी आर्किटेक्चर के साथ खेल रहा हूं, लेकिन मुझे यकीन नहीं है कि जब टैब का चयन किया जाता है तो मैं अलग-अलग टैब के साथ एकाधिक समन्वयक कैसे कर सकता हूं।मैं UIITabBarController के साथ समन्वयक का उपयोग कैसे करूं?
यहाँ मेरी मुख्य एप्लिकेशन समन्वयक वर्ग है ...
protocol UINavigationControllerType: class {
func pushViewController(_ viewController: UIViewController, animated: Bool)
func popViewController(animated: Bool) -> UIViewController?
}
protocol Coordinator: class {
func start()
}
final class AppCoordinator: Coordinator {
// MARK: - Properties
var managedObjectContext: NSManagedObjectContext!
var coordinators = [String : Coordinator]()
var tabController: UITabBarController?
// MARK: - Object Lifecycle
init(moc: NSManagedObjectContext, tabController: UITabBarController) {
self.managedObjectContext = moc
self.tabController = tabController
}
// MARK: - Coordinator
func start() {
guard let tabController = tabController else {return}
let profileNavigationController = NavigationController()
profileNavigationController.tabBarItem = UITabBarItem(title: "Profile", image: UIImage(named: "profileUnselected"), selectedImage: UIImage(named: "profileSelected"))
let plansNavigationController = NavigationController()
plansNavigationController.tabBarItem = UITabBarItem(title: "Plans", image: UIImage(named: "plansUnselected"), selectedImage: UIImage(named: "plansSelected"))
tabController.viewControllers = [profileNavigationController, plansNavigationController]
tabController.selectedViewController = profileNavigationController
let profileCoordinator = ProfileCoordinator(navigationController: profileNavigationController)
profileCoordinator.managedObjectContext = managedObjectContext
coordinators["profileCoordinator"] = profileCoordinator
profileCoordinator.delegate = self
profileCoordinator.start()
}
}
// MARK: - ProfileCoordinatorDelegate
extension AppCoordinator: ProfileCoordinatorDelegate {}
तो जब टैब चयनित होने पर मैं कैसे वर्तमान समन्वयक (ProfileCoordinator) PlansCoordinator से जाना चाहते हैं?
मैं अपने NavigationCoordinators में से एक का एक उदाहरण देख सकते हैं? देर से उत्तर के लिए क्षमा करें। –
मैंने एक उदाहरण शामिल करने के लिए अपना जवाब संपादित किया :) –