use*_*310 3 ios swift eureka-forms
我尝试使用Eureka framework. 但是,选择特定选项后如何隐藏部分?
请帮忙!
let fruits = ["Apple", "Banana", "Coconut"]
form +++= SelectableSection<ImageCheckRow<String>, String>() { section in
section.header = HeaderFooterView(title: "What is your favorite fruit ?")
}
for fruit in fruits {
form.last! <<< ImageCheckRow<String>(fruit) { lrow in
lrow.title = fruit
lrow.selectableValue = fruit
}
}
form +++ Section("xxxxxx Question") {
//hide this section when apple is selected
//$0.hidden =
}
form.last! <<< TextAreaRow() {
$0.title = "Enter description here..."
}
Run Code Online (Sandbox Code Playgroud)
首先为您的水果部分设置一个标签,例如“fruits_section”。然后你可以像这样设置隐藏变量:
$0.hidden = Condition.Function([])
{ form in
if let section = form.sectionByTag("fruits_section") as? SelectableSection<ImageCheckRow<String>, String> {
if section.selectedRow()?.title == "Apple" {
return true
}
}
return false
}
Run Code Online (Sandbox Code Playgroud)
要在第一部分中选择一行时强制评估此隐藏条件,您可以使用onSelectSelectableRow第一部分的 :
(section as! SelectableSection<ImageCheckRow<String>, String>).onSelectSelectableRow = { [weak self] _ in
self?.form.sectionByTag("last_section_tag")?.evaluateHidden()
}
Run Code Online (Sandbox Code Playgroud)
不要忘记为两个部分设置正确的标签。
如果您只有两个部分,您可以使用form.first而不是使用标签form.last,但不推荐使用。
| 归档时间: |
|
| 查看次数: |
2904 次 |
| 最近记录: |