Search code examples
iosswiftuinavigationcontrollernavigationuicontainerview

Navigation doesn't work when I add containerViews from another Mainstoryboard?


ContainerViews and Mainstoryboard

I need to use navigation feature for swipe back in a detail VC, but I can't use this feature via containerView. I can't add the containerView on mainstoryboard. I have to configure containers in another storyboard. Can I create normal navigation between my container views and detail VC?

The VC that I configure container views.

var controller_1: HubTableView = HubTableView.create()
var controller_2: ContainerView = ContainerView.create()

override func viewDidLoad() {
    super.viewDidLoad()
    self.tabBarController?.tabBar.isHidden = false
    self.navigationController?.navigationBar.isHidden = false
    self.reload()
}

func reload() {
    controller_1.delegate = self
    self.viewControllers = [controller_2,controller_1]
}

Solution

  • It should be like this

    UIViewController 
       ContainerView(UIView) -> UINavigationController -> UIViewController
    

    You should embed a UINavigationController in ContainerView , and that navigationController's rootViewController would be a UIViewController(in your case it must be Detail VC).