1

I have a viewController that has x 2 container views in it that hold x 2 different tableViews. I use a segmentControl at the top of the main view to switch between these two tableViews. It works just fine.

On one of the tableViews I want to drill down to show yet another tableView. Problem is, when I do it leaves a blank white space at the top of the view where the segment used to be (at least I think that is what is causing the white space.)

How do I ensure the tableView sits snuggly under the navigation bar?

Here are some images for reference:
1. Is the main view containing a segment control.
2. Is the container view. enter image description here

Selecting a segment brings up a view like the one below. Which is fine.

enter image description here

But when I drill down I get this:

enter image description here

I can scroll up, no problem, and manually place the image under the nav bar, so this tells me its not that the view is not big enough.

How do I remove that white space above the image?

Thanks in advance.

Nirav D
  • 71,513
  • 12
  • 161
  • 183
thecloud_of_unknowing
  • 1,103
  • 14
  • 23
  • Which version of swift or xCode are you using? Have you used size classes or stack view. Did you used constraints for the layout? Can you share the code on github or dropbox so that we can have a look at it? – Jeet Jul 14 '16 at 04:19
  • @Jeetendra Choudhary Swift 2.2; Xcode 7.3.1; No, not using size classes, no, not using stack view; yes I used constraints for the layout IN the cells, all done in StoryBoard. So I haven't got any relevant (view orientated) code to show you. – thecloud_of_unknowing Jul 14 '16 at 04:22
  • In your event details VC try writing self.automaticallyAdjustsScrollViewInsets = NO; this may help :) – Sanman Jul 14 '16 at 04:25
  • set `automaticallyAdjustsScrollViewInsets` to false or select view contrller -> uncheck scroll view insects – Bhavin Bhadani Jul 14 '16 at 04:27
  • Possible duplicate of [UITableView is starting with an offset in iOS 7](http://stackoverflow.com/questions/18388429/uitableview-is-starting-with-an-offset-in-ios-7) – Bhavin Bhadani Jul 14 '16 at 04:27
  • @sanman in viewDidLoad I assume? – thecloud_of_unknowing Jul 14 '16 at 04:27
  • @thecloud_of_unknowing yes in `viewDidLoad` – Nirav D Jul 14 '16 at 04:28

2 Answers2

9

An alternative solution can be this as well. Uncheck the Adjust Scroll View Insets and your problem will be solved.

enter image description here

mshrestha
  • 788
  • 5
  • 14
7

In your EventDetailVC add these line in viewDidLoad method

self.automaticallyAdjustsScrollViewInsets = false

If it not solve set translucent property of navigationBar to true

self.navigationController.navigationBar.translucent = true
Nirav D
  • 71,513
  • 12
  • 161
  • 183