Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Auto Layout and "Hide bottom bar when pushed"

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.

like image 507
Eyal Avatar asked Feb 25 '15 16:02

Eyal


Video Answer


3 Answers

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.

like image 71
Earl Grey Avatar answered Sep 21 '22 18:09

Earl Grey


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

like image 38
Vincenzo Avatar answered Sep 20 '22 18:09

Vincenzo


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).

like image 20
Onik IV Avatar answered Sep 21 '22 18:09

Onik IV