UITabBarController选项卡不出现问题

时间:2019-05-02 12:49:21

标签: uitabbarcontroller swinject

我在以编程方式构建UITabBarController时遇到问题,但是没有选项卡出现,选项卡中心仅一个选项卡,我使用swinject故事板注入我的演示者对象和协调器模式来处理选项卡,只有一个选项卡出现在中间。

我正在使用最新的Xcode,我尝试在不同的模拟器和真实设备上进行构建。

//
defaultContainer.storyboardInitCompleted(MainTabBarController.self) { r,vc in
      let mainCoordinator:MainCoordinator? = r.resolve(MainCoordinator.self)
      mainCoordinator?.homeCoordinator = r.resolve(HomeCoordinator.self)
      mainCoordinator?.homeCoordinator?.navigationController = r.resolve(UINavigationController.self)

      mainCoordinator?.settingsCoordinator = r.resolve(SettingsCoordinator.self)
      mainCoordinator?.settingsCoordinator?.navigationController = r.resolve(UINavigationController.self)

      let  mainPresenter: MainPresenterProtocol = MainPresenter(coordinator: mainCoordinator)
      vc.presenter = mainPresenter

      vc.viewControllers = [(mainCoordinator?.homeCoordinator?.navigationController)! as UINavigationController,(mainCoordinator?.settingsCoordinator?.navigationController)! as UINavigationController]
}

func viewDidLoad()
{
  super.viewDidLoad()
  coordinator?.start()
}

func start()
{
  homeCoordinator?.navigationController.tabBarItem = UITabBarItem(title: "Home", image: UIImage(named:"ic_home"), selectedImage: UIImage(named:"ic_home"))
}

0 个答案:

没有答案