Search code examples
iosswiftxcodeuitabbarcontroller

Tab bar not visible on coming back to selected item


I am facing a strange issue with Tab bar controller. I have a tab bar controller in main.storyboard working fine. I have 5 different storyboard references for each item and I could see all 5 tabs and tab bar is working fine in the simulator.

On selecting the 3rd tab, there is a button in 1st view controller that pushes to second view controller, here I am hiding the tab bar in viewWillAppear. Then when I push to 3rd view controller, I am showing the tab bar again in viewWillAppear.

Now when I select some other tab item from 3rd view controller and come back to 3rd tab, tab bar is not visible even though i have written below code:

override func viewWillAppear(_ animated: Bool) {
    tabBarController?.tabBar.isHidden = false
}

Solution

  • Finally figured out the issue. One of my view controller in storyboard had hide tab bar on push view controller enabled causing the tab bar to hide in my expected view controller. On unchecking it and handling all hide/show tab bar in source code itself, i am able to fix the issue.