0

When my iOS app loads, there is a tab view controller that gets loaded with 3 tabs: charge, location, more. When you click on more, there is a option to to sign in. When the clicks on sign in -> signviewcontroller gets shown where the user chooses their Google profile to sign in -> once successful, they should be directed to the Charge page. If user does not sign in which would be the first time the app loads, normal tabs should be shown -> charge, location, more.

The problem is that I am not sure if I have aligned my TabViewController and my NavigationController correctly. Once sign in is clicked, Signviewcontroller does get shown and I also segue into ChargeViewController but I dont see the tabs and the navigation bar item name charge although there is a blank navigation bar.

Here is my segue code:

self.performSegue(withIdentifier: "signin_complete", sender: self)

Here is my storyboard layout, tried to extract the problem and showed below: enter image description here

Should I layout my view controllers differently? I read that I need to add navigationcontroller which would fix the bottom tabs but it did not.

GIF of what it looks like and notice how the last page charge does not show any tabs at the bottom. gif link

fscore
  • 2,567
  • 7
  • 40
  • 74
  • Is this something you wanted? https://stackoverflow.com/questions/29458948/how-to-use-navigation-controller-inside-of-uitabbarcontroller-with-storyboard-on – Ruchi Jun 15 '17 at 04:11
  • you need to set as rootViewController instead of push . **let appDelegate = UIApplication.shared.delegate as! AppDelegate appDelegate.self.window?.rootViewController = tabBarController** – KKRocks Jun 15 '17 at 04:57

1 Answers1

0

You should remove segue that is between Signviewcontroller and Navigation Controller - ChargeViewController. Then Tabbar will be appeared on this navigation controller like Location.

Here my example:

With Segue Without TabBar

Without Segue With TabBar

Then you should create own UITabBarController class. After that you can control your view controllers inside tabBar didSelect. Check signing status and root SignViewController or ChargeViewController.

override func tabBar(_ tabBar: UITabBar, didSelect item: UITabBarItem) {
    let nav: UINavigationController = self.tabBarController?.viewControllers?.first as! UINavigationController
    //get sign or charge view controller
    nav.setViewControllers([sign or charge], animated: true)
}
a.u.b
  • 1,589
  • 10
  • 25