Reputation: 1443
I have a UITableView
in a UIViewController
in a UINavigationController
in a UITabBarController
.
In my UITableView
, I have section headers, and all sections have 60 pixel height. Set like this.
tableView.sectionHeaderHeight = 60
My UITableView
also have Grouped
for style attribute.
The problem is, there is empty space above my UITableView
and I want to get rid of it.
The problem only occurs on iPads, there is no empty space on smaller devices. (I simulated on iPad 2 and iPhone 6 respectively.) Because of this solution #3 does not work.
Some of the solutions I have tried but did NOT work:
self.automaticallyAdjustsScrollViewInsets = false
tableView.contentInset = UIEdgeInsetsZero
self.tableView.contentInset = UIEdgeInsetsMake(-64, 0, 0, 0)
Does not work for all devices. Because my table already works good in some devices and this makes it go out of screen on them.
UITableView
style to Plain
instead of Grouped
.This works, but I need my headers to be Grouped style not plain. So I can't use this.
So what are my options here? Thanks in advance.
Upvotes: 2
Views: 289
Reputation: 8011
Change the UITableView
's Style
property to plain
in interface builder, like following.
Upvotes: 1
Reputation: 4096
You need to uncheck adjust scrollview insets
property by selecting relevant viewController
see below image:
Hope this helps.
Upvotes: 1