Starting in iOS7, there is additional space at the top of my UITableView
's which have a style UITableViewStyleGrouped
.
Here is an example:
The tableview starts at the first arrow, there are 35 pixels of unexplained padding, then the green header is a UIView
returned by viewForHeaderInSection
(where the section is 0).
Can anyone explain where this 35-pixel amount is coming from and how I can get rid of it without switching to UITableViewStylePlain
?
Update (Answer):
In iOS 11 and later:
tableView.contentInsetAdjustmentBehavior = .never
UITableView
doesn't like to be assigned a header with a height of 0.0. Check stackoverflow.com/a/31223403/1394534 for more details. – Aurelien Porteself.tableView.tableHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 0.0f, CGFLOAT_MIN)];
note:0.0f
is just ignored if you use it in the height of the rect. So we use the nearest-to-zero CGFloat possible (at least this "worked" for me... just not ideal solution). – Alejandro Iván