1

I can hide the tab bar programmatically. The view underneath is a scrollview displaying content. When I scroll up/down I can see the white space at the bottom where the tab bar used to be. My content is not able to use that space.

I want to display a text box in that white space along with some buttons. Any suggestions on how can I do that?

Solution: Thanks to "SwiftArchitect" advice. I was able to fix this by adding bottom constraints for the ScrollView. Now the scrollview goes till the bottom of the screen.

Curious101
  • 1,538
  • 2
  • 18
  • 36
  • In a standard view Controller I added a scroll View and then in viewDidLoad method of the view controller I enabled the Srcoll view as follows: myScrollView.scrollEnabled = YES; myScrollView.contentSize = CGSizeMake(370, 700); [myScrollView scrollRectToVisible:CGRectMake(myScrollView.contentSize.width - 1, myScrollView.contentSize.height - 1, 1, 1) animated:YES]; I'm using objective C and in viewDidLoad method of a standard View Controller I made this call to hide the tab bar: self.tabBarController.tabBar.hidden=YES; Yes, I am using auto layout – Curious101 Aug 10 '15 at 00:41
  • I tried to do +1, but it won't let me. Apparently I need 15 reputation points before it would let me +1 the solution. – Curious101 Aug 11 '15 at 22:20
  • (-: I really appreciate. I have posted a link to the ViewLayoutAssistant which is a useful class you should use anywhere you have layout concerns: https://gist.github.com/SwiftArchitect/003be02e89204cad8fea – SwiftArchitect Aug 13 '15 at 02:45

1 Answers1

1

As often is the case with AutoLayout, this question becomes trivial when using Storyboard and either the ViewLayoutAssistant or an image which will show evidence of resizing.

Let's assume that you are adding 4 constraints for your scroll view:

  1. vertical space view.top (0) equal to Top Layout Guide.bottom
  2. vertical space view.bottom (0) equal to Bottom Layout Guide.top
  3. and 4. horizontal leading and trailing space

...then when hiding the tabBar:

if let tabBarController = self.tabBarController {
    tabBarController.tabBar.hidden = true
}

the view.bottom, anchored to the Bottom Layout Guide.top, will now stretch all the way to the bottom. If you add a UILabel above that line, it will show.

Here is what it would look like in the Storyboard:

A storyboard with a navBar and 2 UIViewControllers

When executed with the ViewLayoutAssistant, the UIViewController that hides the navBar as follow will look like this (notice that the view now stretches all the way to the bottom since the Bottom.Layout.Guide moved down):

enter image description here

SwiftArchitect
  • 47,376
  • 28
  • 140
  • 179
  • 1
    I added constraints so now it goes till the bottom of the screen. When the tab bar is hidden the scrollview takes up that space as well. – Curious101 Aug 10 '15 at 20:49