I fought with section heights for several hours when I was getting started. Basically, my code base uses "blank" sections as a way to group rows together and hide them without having their individual properties set to hidden.
This is nice, because you can distinguish between rows hidden individually b/c they don't apply (so should not be validated) from rows that are hidden b/c of their section, and should be validated.
Anyway, after messing around for a long time, I solved all my problems by setting the section height in the Storyboard editor for the TableView to 1. Before that, I could not make the sections "short/empty" no matter what I did with code.
I pulled an update to Eureka, worked for about 10 hours on all sorts of stuff, and now I just noticed my sections are big again and changing the section height in Story board editor has no effect.
Was there an upstream change that would have caused this?
Would it be possible to create an easy way to make minimum-height sections?
Sorry folks. For some time when I was trying to learn about how to setup Toolbars at the bottom of views I had all sorts of extra views that were not necessary. Sometimes these were working, but I guess sometimes they were not. So, I removed the TableView that I had manually added in Storyboard because Eureka handles that automatically. So, how to adjust the section height?
Well, you can override a function and write some code to see if the section is one of the ones you want to be near-invisible, and otherwise fall back to default Eureka logic.
Looks something like:
internal override func tableView(tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
if let theView:Section=form[section]{
if let theTag = theView.tag{
if theTag.containsString("Hidden") || theTag.containsString("Spacer") || theView.header?.title == nil{
return 1;
}
}
}
return super.tableView(tableView, heightForHeaderInSection: section);
}
Maybe that will help someone else. You can do the same for the footer too.
@btanner Have you tried..
Section() { section in
var header = HeaderFooterView(title: "")
header?.onSetupView = { view, _, _ in
}
header?.height = { 1 }
section.header = header
}
For more information see: https://github.com/xmartlabs/Eureka#section-header-and-footer
Yeah that's probably much better. I'll have to muck with it at home a bit more to get it right for my setup, but a quick test and it does what I want without having to override which is a bonus :)
Thanks very much!
:+1:
I don't think onSetupView gets called for HeaderFooterView(title: ), as it looks like there is no viewProvider
This might explain why I can't get the sizes right down near 0 when I have a couple of these sections stacked on each other in different configurations. I stopped messing around with it after a while. I turned off the separator line so the varying small sized "hidden" sections became less noticeable.
Most helpful comment
@btanner Have you tried..
For more information see: https://github.com/xmartlabs/Eureka#section-header-and-footer