Auto Layout and "Hide bottom bar when pushed"

22,633

Solution 1

The problem is with this specific constraint which is between the view and the top of the bottom layout guide.

enter image description here

Select the constraint and edit its "Second Item" property

enter image description here

Here you need to choose bottom

enter image description here

Once you have that, the pink view is not influenced by layout guide anymore. The layout guide seem to acknowledge that the tab bar is hidden only after the root view of the pushed view controller is in the bounds of main screen and this happens only when the animation is finished.

And that is the reason the view hierarchy needs to be laid out again which causes the unwanted animation.

Solution 2

The accepted answer did not work for me (the option was not available). However I have found another solution. (based on Hide Bottom Bar When Pushed through Autolayout)

Select booth the view and the object to align (in my case btnShare) and add a new alignment constraint (Bottom Edges).

enter image description here enter image description here

Solution 3

Hi In storyboard select Tab bar (Is Tab Bar Controller Scene > Tab Bar Controller > Tab Bar ), in the attribute inspector, uncheck Translucent box. This action fix your problem. (But there are many things, "Hide bottom bar when pushed" is to toolbar).

Solution 4

IF you can't select bottomlayoutguide bottom in your Xcode 7+

like there just do the following: open your storyboard in source code editor

open in editor search your controller's identifier

search in source file find <layoutGuides>, type <bottom>, copy it id

find layoutGuides search by id change attribute from top to bottom

find and replace enjoy.

Solution 5

Select your "Navigation Controller" and in "Attribute Inspector" remove the checkmark from "Under Bottom Bars".

Share:
22,633
Eyal
Author by

Eyal

Updated on July 09, 2022

Comments

  • Eyal
    Eyal almost 2 years

    My app's (simplified) structure is this:

    UITabBarController with one UINavigationController holding a UITableViewController as root view controller.

    when tapping one of the table view controller cells, I push a regular UIViewController (lets call it VC) end hiding the bottom tab bar. (using the "Hide bottom bar when pushed" flag)

    In storyboard I added a regular UIView subclass to VC that look like a bottom bar, and I use Auto Layout to pin it to the bottom of the VC view.

    The problem
    when I push VC it takes a second for this view to pin to the bottom, it looks like auto layout pin it to the bottom as if the tab bar is not hidden and after a sec it recognise that the tab bar is hidden and moves it to the real bottom of the view.

    I know its not the best explanation, so I added a very simple project to demonstrate the issue.

  • Eyal
    Eyal about 9 years
    but now the tab bar is visible when I push VC, I need it to be hidden.
  • Onik IV
    Onik IV about 9 years
    At least, in the example project you have shared (AutoLayoutTest), if you only uncheck translucent property in the tab bar, the tab bar disappear when you push and the violet view appear in its place. (Test you own project)
  • Eyal
    Eyal about 9 years
    the problem with this solution is that you see the disappearing / appearing of the tab bar. especially when using the swipe back gesture.
  • rdelmar
    rdelmar about 9 years
    @Eyal, I edited my answer to show ways to improve the animation.
  • Eyal
    Eyal about 9 years
    im not comfortable with this kind of solution, hiding/showing the tab bar on viewWillAppear/viewWillDisapear is a bit risky i think. it seems that "hide bottom bar" works great without auto layout, so I wonder if there is something to do with the auto layout configuration.
  • rdelmar
    rdelmar about 9 years
    @Eyal, what's wrong with Onik IV's solution? I don't see the tab bar either when I uncheck the translucent property for the tab bar (and hide's bottom bar on push is still checked).
  • DogCoffee
    DogCoffee almost 9 years
    When autolayout will not work stackoverflow.com/questions/29334285/…
  • Greg
    Greg over 8 years
    @AnthonyM I ran into that problem as well. I ended up editing the storyboard's source by hand so that I could change the constraint's item to use bottom layout guide.bottom.
  • aaddesso
    aaddesso over 8 years
    @AnthonyM it's a bit hidden in Xcode 7 but it's there: stackoverflow.com/a/33432500/125407
  • alionthego
    alionthego over 8 years
    just wondering how you managed to edit storyboard source by hand so that you could change the constraint's item to use bottom layout guide.bottom? I've been stuck on this for sometime now and don't understand why I can't just select bottom in storyboard anymore?
  • Ashkan Ghodrat
    Ashkan Ghodrat over 7 years
    worked for me, but i m looking for any future bug it may cause.
  • Peterdk
    Peterdk over 6 years
    This did not work for me, I still get 1s of white space displayed when pushing ViewController.
  • Sudhakar Tharigoppula
    Sudhakar Tharigoppula about 6 years
    Super...Very useful
  • thetrutz
    thetrutz about 5 years
    Yes, this is the correct answer. Set "Hide bottom bar on push" on the view controller, that should not show the tab bar. Don't set it on the tab bar controller, the navigation controller or on the parent view controller of your controller.