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:
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
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:
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)
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.