Eureka: PushRow how to set footer of section

Created on 9 Oct 2016  路  5Comments  路  Source: xmartlabs/Eureka

I didn't figure out how to do that. onPresent method is called before viewDidLoad()

PushRow section header footer SelectableSection

Most helpful comment

@mohan-shyam PushRow has not section setter explicitly, but I resolved this issue with this code myself

        .onPresent { (form, selector) in
            selector.enableDeselection = false
            selector.selectableRowCellUpdate = { (cell, row) in
                guard selector.form.last?.footer == nil else {
                    return
                }
                let footer = "Footer text here"
                selector.form.last?.footer = HeaderFooterView(title: footer)
                selector.tableView?.reloadData()
            }
        }

All 5 comments

@amosavian , you don't setup header/footer for a row (PushRow,..,...,). It is only for a section, as far as I know. And if I understand your issue correctly, below is my solution.

+++ Section(header: "header",footer: "footer")

@mtnbarreto , Actually I was wondering, if the footer can be changed dynamically based on the row value?

@mohan-shyam PushRow has not section setter explicitly, but I resolved this issue with this code myself

        .onPresent { (form, selector) in
            selector.enableDeselection = false
            selector.selectableRowCellUpdate = { (cell, row) in
                guard selector.form.last?.footer == nil else {
                    return
                }
                let footer = "Footer text here"
                selector.form.last?.footer = HeaderFooterView(title: footer)
                selector.tableView?.reloadData()
            }
        }

@mohan-shyam @amosavian You can also do something like this:

                <<< PushRow<Emoji>() {
                        $0.title = "PushRow"
                        $0.options = [馃拋馃徎, 馃崘, 馃懄馃徏, 馃悧, 馃惣, 馃惢]
                        $0.value = 馃懄馃徏
                        $0.selectorTitle = "Choose an Emoji!"
                    }
                    .onPresent({ (form, selectorVC) in
                        let _ = selectorVC.view // will make controller invokes viewDidLoad
                        // first section is now available and we can set it up
                        selectorVC.form[0].header = HeaderFooterView<EurekaLogoViewNib>(.nibFile(name: "EurekaSectionHeader", bundle: nil))
                    })

screen shot 2016-10-21 at 2 29 56 pm

@mohan-shyam you can change section header, footer at any time but you will be in charge of calling section.reload() to refresh the UI.

Was this page helpful?
0 / 5 - 0 ratings