xmartlabs / Eureka

Elegant iOS form builder in Swift
https://eurekacommunity.github.io
MIT License
11.78k stars 1.33k forks source link

Section Header Views should not use default height from nib #1780

Open coinbump opened 5 years ago

coinbump commented 5 years ago

If you load a section header view from a nib, the logic for determining whether to use automaticDimension is incorrect (code is below):

A view loaded from a nib has a default height, but that is almost never the true height of the section header view since any changes in labels or the system-wide dynamic text sizes will result in this value being wrong.

This logic is incorrect.

In Core.swift:


        if let height = specifiedHeight {
            return height()
        }

        if let sectionView = sectionView {
            let height = sectionView.bounds.height

            if height == 0 {
                return UITableView.automaticDimension
            }

            return height
        }```
mats-claassen commented 5 years ago

Well, using automaticDimension by default would also not be correct because I can imagine that many times the height of a header or footer view is not completely defined by its constraints.

And it is still easy to define the height variable of the header or footer when defining it:

header?.height = { UITableView.automaticDimension }

What do you think?

coinbump commented 5 years ago

Personally, I like automaticDimension better, but it's up to the authors of this project.

If you have a sectionHeader, even if it only has a label, that label might be using dynamic type, which can be dynamically sized so a fixed size won't make sense.

Also, I'm used to projects where every view is loaded from a xib, not created programatically, so it's standard to have UI constraints.

mats-claassen commented 5 years ago

I get what you mean but defaulting to .automaticDimension would disable the option of setting the height of the view like it is in the xib file.

That is why I'd prefer to leave it as it is. Just set header.height to .automaticDimension