Present ViewController in front of UITabBarController's tabBar and hide this tabBar

In my project I have a UITabBarController. And on one of it's ViewControllers I have button. When I click this button, a new ViewController is presenting modally.

The problem is, when the second VC is presenting, tabBarController's tabBar is still visible. When I try to hide it in first ViewController's action openFiltersList() with this method:

self.tabBarController?.tabBar.hidden = true

it hides, but when I'm trying to unhide it, when I dismiss second VC, setting this parameter to falsedoesn't work, tabBar stays hidden. Here's the code for first and second:

First (InvitesViewController, one of the tabBarController's View Controllers):

func openFiltersList() {

        var filtersView : UIViewController = self.storyboard?.instantiateViewControllerWithIdentifier("filtersViewController") as! FiltersViewController
        filtersView.modalPresentationStyle = UIModalPresentationStyle.OverCurrentContext


        self.presentViewController(filtersView, animated: true) { () -> Void in

            UIView.animateWithDuration(0.3, animations: { () -> Void in

                filtersView.view.backgroundColor = UIColor(red: 0.0/255.0, green: 0.0/255.0, blue: 0.0/255.0, alpha: 0.5)

            })

        }

        self.tabBarController?.tabBar.hidden = true

    }

Second (FiltersViewController, not embedded anywhere):

@IBAction func dismiss(sender: AnyObject) { // close button action

        self.dismissViewControllerAnimated(true, completion: nil)

        var destinationVC : UIViewController = self.storyboard?.instantiateViewControllerWithIdentifier("invitesViewController") as! InvitesViewController
        destinationVC.tabBarController?.tabBar.hidden = false

    }

I'm using storyboard for interface.

Answers


You should present the new viewController from tab bar controller:

 self.tabBarController?.presentViewController(filtersView, animated: true) { () -> Void in

        UIView.animateWithDuration(0.3, animations: { () -> Void in

            filtersView.view.backgroundColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0.5)

        })

    }

Need Your Help

How can I access Docker set Environment Variables From a Cron Job

cron environment-variables docker

I've recently tried running a cron job from within a linked docker container and run into an issue. My main docker container is linked to a postgres container and its port number is set as an envir...

Why should I use the keyword "final" on a method parameter in Java?

java pass-by-reference final pass-by-value

I can't understand where the final keyword is really handy when it is used on method parameters.