0

I'm developing a swift application. I need when I click in a item inside a table it will open a new view. That's fine and working, but te bottom buttons of the tab bar still there. How can I do to this disappear?

Code used to call the next screen. I've tested some different ways but this was the only one that worked fine.. I think this is not the problem in here..

func irParaMarcacoes(nome:String){
    let next:ViewMarcacaoController = storyboard?.instantiateViewControllerWithIdentifier("ViewMarcacaoController") as! ViewMarcacaoController
    next.projNome = nome;
    self.navigationController?.pushViewController(next, animated: true)
}

This is what I have, the first screen

This is what I want the tap bar to disappear

Thanks for yout attention.

*Using XCode 7.3

Xidh
  • 582
  • 1
  • 5
  • 19
  • This is not a Navigation Bar, what you try to hide is Tab Bar. Try self.tabBarController?.tabBar.hidden = true in viewDidLoad() – Engnyl May 05 '16 at 12:21
  • Yes! Thats right! This is Tap Bar! Just eddited. Thanks – Xidh May 05 '16 at 12:25

4 Answers4

1

you can hide navigation bar. write this code in ViewMarcacaoController

override func viewDidLoad() {

    super.viewDidLoad()
    self.navigationController?.navigationBarHidden = true
}
Diogo Rocha
  • 9,759
  • 4
  • 48
  • 52
shalu tyagi
  • 148
  • 8
0

You are pushing view controller from navigation bar

so your controller you are pushing is the top view controller of it

so in view will appear method

self.navigationController!.setNavigationBarHidden(true, animated: animated)

to hide bottom bar

self.tabBarController?.tabBar.hidden = true
Prashant Tukadiya
  • 15,838
  • 4
  • 62
  • 98
  • I'm sorry.. o probably expressed myself wrong. I think the name is not Navigation Bar, it is Tap Bar. I want the top bar to stay, but the bottom bar to disappear. Thank you – Xidh May 05 '16 at 12:24
  • self.tabBarController?.tabBar.hidden = true will help – Prashant Tukadiya May 05 '16 at 12:25
  • This work when I click inside the tap bar right? Can I do this using a function? For instance, force it to go away when I want, without wait the user click in the tap bar? – Xidh May 05 '16 at 12:30
  • can you please explain what you exactly want ? – Prashant Tukadiya May 05 '16 at 12:32
  • I found a way right now! Thanks very much for your attention. I will post bellow what I found! – Xidh May 05 '16 at 12:35
0

I found a great solution provided by Michael Campsall in here.

the solution consist basically on:

func setTabBarVisible(visible:Bool, animated:Bool) {

//* This cannot be called before viewDidLayoutSubviews(), because the frame is not set before this time

    // bail if the current state matches the desired state
    if (tabBarIsVisible() == visible) { return }

    // get a frame calculation ready
    let frame = self.tabBarController?.tabBar.frame
    let height = frame?.size.height
    let offsetY = (visible ? -height! : height)

    // zero duration means no animation
    let duration:NSTimeInterval = (animated ? 0.3 : 0.0)

    //  animate the tabBar
    if frame != nil {
        UIView.animateWithDuration(duration) {
            self.tabBarController?.tabBar.frame = CGRectOffset(frame!, 0, offsetY!)
            return
        }
    }
}

func tabBarIsVisible() ->Bool {
    return self.tabBarController?.tabBar.frame.origin.y < CGRectGetMaxY(self.view.frame)
}
Community
  • 1
  • 1
Xidh
  • 582
  • 1
  • 5
  • 19
0

Enable the Hide Bottom bar on Push on your second screen View controller in storyboard as shown in following :

enter image description here

So when you push your viewcontroller, it will hide the bottom Tab bar. When you come back to firstViewController, then tab bar will be shown. No need to write code for this.

Hope it helps..

Balaji Ramakrishnan
  • 1,909
  • 11
  • 22