Eureka: Autosizing headers

Created on 14 Dec 2015  路  3Comments  路  Source: xmartlabs/Eureka

Can I use autolayout for sizing section headers? Setting header.height to nil doesnt seem to work.
Is there a reason that you support autosizing cells and dont support autosizing headers?

Is there a way to force layout of the actual view in the header.height closure (without keeping another instance of the same view for layout purposes)?

Section { s in
            var header = HeaderFooterView<MyFormSectionHeaderView>(.Class)
            header.onSetupView = { v, _, _ in
                v.label.text = "Description"
            }
            header.height = { /*use autolayout to layout 'v' from onSetupView */ 42  }
            s.header = header
     }
section header footer awaiting response question

Most helpful comment

You can do it by returning UITableViewAutomaticDimension for the header footer height....

Section() {
     var header = HeaderFooterView<EurekaLogoViewNib>(HeaderFooterProvider.NibFile(name: "EurekaSectionHeader", bundle: nil))
     header.onSetupView = { (view, section, form) -> () in
          // ..
     }
     header.height = { UITableViewAutomaticDimension }
     $0.header = header
}

You have also to set up estimatedSectionHeaderHeight and estimatedSectionFooterHeight...

    override func viewDidLoad() {
        super.viewDidLoad()
        tableView?.estimatedSectionHeaderHeight = 20
        tableView?.estimatedSectionFooterHeight = 20

Let me know if this works in your app...

All 3 comments

You can do it by returning UITableViewAutomaticDimension for the header footer height....

Section() {
     var header = HeaderFooterView<EurekaLogoViewNib>(HeaderFooterProvider.NibFile(name: "EurekaSectionHeader", bundle: nil))
     header.onSetupView = { (view, section, form) -> () in
          // ..
     }
     header.height = { UITableViewAutomaticDimension }
     $0.header = header
}

You have also to set up estimatedSectionHeaderHeight and estimatedSectionFooterHeight...

    override func viewDidLoad() {
        super.viewDidLoad()
        tableView?.estimatedSectionHeaderHeight = 20
        tableView?.estimatedSectionFooterHeight = 20

Let me know if this works in your app...

Check out issue #134. It should be helpful.

it doesn't work

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tc picture tc  路  3Comments

Tomas1405 picture Tomas1405  路  3Comments

tomasKa picture tomasKa  路  4Comments

JonathanImperato picture JonathanImperato  路  3Comments

Sweeper777 picture Sweeper777  路  3Comments