Closed yunhao closed 3 years ago
This change has caused problems in my project. How can I explicitly set the header title to be row.title if needed? The code change now always sets it to nil. It looks like I could maybe set the header title via optionProvider options but I haven't been able to figure out the right syntax for that. Is there a certain attribute I should use when creating the PushRow?
You should be able to set section header using sectionKeyForValue
and sectionHeaderTitleForKey
on the SelectorViewController
@mats-claassen that solution doesn't work for me because our design is that there is only 1 section, and that section needs a header title. sectionHeaderTitleForKey doesn't get called because optionsBySections returns nil. Therefore, my code reaches the else in setupForm where header is always set to nil. I don't see a way to override it.
@kamerc for single section setups you could set sectionKeyForValue
to a closure that always returns the same key, right? Then optionsBySections
will not return nil and sectionHeaderTitleForKey
will be used
@mats-claassen that solution was going to be my workaround, I just wanted to know first if there was a better way. Is the best way to access sectionKeyForValue on the SelectorViewController via onPresent? For example, what I have below:
PushRow<string>(tag) {
$0.options = ['1', '2']
$0.onPresent { from, to in
to.sectionKeyForValue = { option in
return "my heading title"
}
}
}
Yes, that looks right
If we use
PushRow
to push a SelectorViewController with only one section, then the section title will be set torow.title
by default, although we don't explicitly do so. Look at the 1st picture.The behavior, that the section title has a default value, is quite confusing. It's different from the default behavior of
UITableView
. The row title has a strong correlation with the pushed view controller title, but not with the section title.Actually, when there is only one section, we only need a view controller title instead of a section title. Look at 2nd picture.
We should remove the default value, and let developers explicitly set the title if they need it.