Search code examples
iosswiftuitableviewuitabbarcontrollertabbar

Adding TabBar Pushes Cells and View Up [Swift]


When I add a TabBar to my VC the cells in the view all move up, covering a part of the cell under the header.

Here is an image that shows the VC without the TabBar:

enter image description here


This is with the TabBar:

enter image description here

(Don't mind the black screen/video screen please. Not relevant)

When I scroll up when the TabBar is there, the "scroll/UIACtivityView" disappears as well. It loads, but it doesn't have an activity indicator.

I have to scroll up to see the picture where it shows the name "Selected"

Anyone know why the TabBar pushes up the whole view? If so, how do I prevent that?

Any help means a lot.

Thanks.


Solution

  • I'm using a TabViewController and I checked "Adjust Scroll View Insets" in the MainStoryboard Attributes Inspector and it fixed the issue.

    (Select the TabViewController/Root View and THEN adjust Scroll View Insets)

    The cells/view don't hide behind the header anymore.

    The Adjust Scroll View Insets definition:

    "A boolean value that indicates whether the viewController should automatically adjust its scroll view insets."
    

    I used this link as a reference:

    UITableView embedded in other view has wrong position of section header

    Hope that helps others!