Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove vertical space between sections in a Grouped UITableView

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)?

like image 940
Daniel Faria Sampaio Avatar asked Nov 29 '22 06:11

Daniel Faria Sampaio


1 Answers

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!

like image 135
Daniel Faria Sampaio Avatar answered Dec 19 '22 16:12

Daniel Faria Sampaio