1

I am trying to hide my tabBar when pushing to a new viewController. I achieve this by ticking Hide Bottom Bar on Push in storyboard. The problem is that the new view that is being pushed to momentarily shows it's original position (as if the tabBar was still there) before shifting downwards to the correct position.

After searching for some time I found a similar post: Auto Layout and "Hide bottom bar when pushed"

Unfortunately the solution of selecting the bottom constraint of the new view to Bottom Layout Guide.Bottom is no longer available in iOS 9 (it is greyed out). I followed several suggestions to set the bottom constraint to the container margin but it did not help this shift downwards.

Has anyone found a solution for this problem? It seems the geometry of hiding the tabBarController is only recognised after the push transition has completed.

Community
  • 1
  • 1
alionthego
  • 8,508
  • 9
  • 52
  • 125
  • hide the tabbar on viewDidLoad of pushed class – Jaimish Nov 27 '15 at 07:10
  • i tried that by adding self.tabBarController!.tabBar.hidden = true on the pushed viewController in viewDidLoad. Same thing happens. – alionthego Nov 27 '15 at 07:11
  • Well in iOS 9 with XCode there is a way around for setting the bottom layout. I am gonna post a solution related to it. – Hanny Nov 27 '15 at 08:23

2 Answers2

2

It turns out my inputAccessoryView was causing the odd scrolling behaviour. The solution that worked for me was to add view.layoutIfNeeded() just before returning the accessoryView in the override:

override var inputAccessoryView: UIView? {
     get {
        view.layoutIfNeeded()
        return accessoryView
     }

So for this special case that involves a navigationController embedded in a tabBarController where you like to push to a viewController that hides the tabBar:

  1. check Hide Bottom Bar on Push on storyboard

  2. pin the bottom of the view you are presenting to the container bottom (use method suggested above or just select the pin icon at the bottom of your screen and on the bottom constraint select the drop down arrow and pin to view)

  3. Then finally if you are using an inputAccessoryView, add layoutIfNeeded() in the override to the getter as I have done above.

alionthego
  • 8,508
  • 9
  • 52
  • 125
1

In Xcode7 you have to right click your element, draw a line to the bottom until the constraint selector pops up. Constraint selector

enter image description here

Then press ALT and now you'll get the desired Bottom constraint

enter image description here

Hanny
  • 1,322
  • 15
  • 20
  • Yes, I've come across this too and tried it but it doesn't work also. I can still see the view shifting down. What you are doing can also be achieved using the pin tool at the bottom of storyboard and selecting the drop down arrow next to the bottom pin constraint. Still I can see the view jump down after the view transition is complete. Previously by selecting Bottom Layout Guide.Bottom I did not have any problems. Using your solution and using the container bottom is not working for me. – alionthego Nov 27 '15 at 08:27
  • actually I've just slowed down the animation and what is different now by using your solution is that the collectionView which is being presented in the pushed viewController is scrolling while it is appearing rather than being scrolled already to the bottom already. The scroll is visible now which I don't want. – alionthego Nov 27 '15 at 08:31
  • so to be clear, if I set the bottom constraint to the bottom layout guide, the view appears already scrolled and perfectly correct except that it shifts down after the transition is complete. If I just change the bottom constraint to the container bottom as you suggest, the view scroll is happening during the transition of viewController's in a visible manner. – alionthego Nov 27 '15 at 08:42
  • i should also mention that the viewController I am transitioning to contains and inputAccessoryView. If I remove this the scroll effect is gone and everything works normally. So somehow using the bottom container constraint with an input accessoryView is causing the problem. – alionthego Nov 27 '15 at 09:00