Search code examples
swiftuitabbarcontrolleriphone-xxcode9.2

Hiding Bottom Bar When Pushed - Animation freezing on Iphone X


I've encountered an issue that I cannot figure out for the life of me. The issue is only happening on the iPhone X. I've added a little video since its difficult to explain exactly whats happening.

I've also added a screenshot of my storyboard so you can see the flow.

Pretty much were experiencing a freeze when the tab bar is being hidden. It only happens when we visit the category VC (which is presented modally using a segue, it is also embedded in a navigation controller.)

** I'm still new to iOS development so if I'm doing anything terribly wrong feel free to share :)

Video: https://youtu.be/HC14zFxh-HM

Code that sends to reader:

@IBAction func sendToReader(_ sender: Any) {
    let myVC = storyboard?.instantiateViewController(withIdentifier: "ReaderRootVC") as! ReaderRootVC
    myVC.book = self.book
    myVC.hidesBottomBarWhenPushed = true
    navigationController?.pushViewController(myVC, animated: true)
}

Code that closes Category VC:

@IBAction func navigationCancelBtnPressed(_ sender: Any) {
    self.navigationController?.dismiss(animated: false, completion: nil)
}

Storyboard: enter image description here


Solution

  • In your ReaderRootVC,

    override func viewWillAppear(_ animated: Bool) {
            super.viewWillAppear(animated)
            // Hide the Tab Bar
            self.tabBarController?.tabBar.isHidden = true
        }
    
        override func viewWillDisappear(_ animated: Bool) {
            super.viewWillDisappear(animated)
    
            // Show the Tab Bar
            self.tabBarController?.tabBar.isHidden = false
        }