5

I've been searching for this one for quite a while and didn't find a solution that works for me.

I've setup the UITableView as Grouped and each section header will hold a UIView that will be used to represent a question on a question-answer application and each section will hold a number of rows that will be used to represent the answers to that previous question.

The problem is: there is a vertical spacing between each section group, and I want to remove it.

Captions on red to explain

I already tried to do like suggested in here but looks like it didn't worked.

I also tried using a minimal value for the estimatedHeightForFooterInSection as 0.00001 as suggested here. But I'm getting the following error:

'section footer height must not be negative - provided height for section 1 is -0.000010'

Is there a way to make this work without abandoning the strategy (section for question, rows for answers)?

Community
  • 1
  • 1
  • https://developer.apple.com/reference/uikit/uitableviewdelegate/1614967-tableview. Use this function. – Sachin Vas Dec 02 '16 at 17:25
  • Is there any particular reason you're using a grouped tableview instead of a plain one? A plain one shouldn't have that spacing in there by default. – tww0003 Dec 02 '16 at 18:20
  • 1
    Yes @tww0003, I cannot allow the section header to remain fixed on top while scrolling in the section content. I just tested changing it to `Plain` and it worked, but then there's that problem that I just mentioned. – Daniel Faria Sampaio Dec 02 '16 at 18:28

1 Answers1

27

For some reason tableView.estimatedSectionFooterHeight = 0.0 was not working but tableView.sectionFooterHeight = 0.0 did, even with the UITableView.style = .grouped.

Also I was using an empty UIView as my footer view.

tableView.tableFooterView = UIView(frame: CGRect.zero)
tableView.sectionFooterHeight = 0.0

Thanks for all your help!