我有这段代码:
form +++= SelectableSection<ImageCheckRow<String>, String>("branch_section", selectionType: .MultipleSelection) { section in
section.header = HeaderFooterView(title: "Branches")
}
for branch in sharedBranch.branchList {
form.last! <<< ImageCheckRow<String>(branch.name){ row in
row.title = branch.name
row.baseValue = branch.id
row.selectableValue = branch.name
row.value = nil
}
}
但是我无法获得selectedRows
,我试过了:
let branch_section = self.form.sectionByTag("branch_section") as? SelectableSection<ImageCheckRow<String>, String>
print(branch_section)
print(branch_section.selectedRows())
同时打印nil
答案 0 :(得分:2)
为此,您需要使用此
form +++= SelectableSection<ImageCheckRow<String>, String>("branch_section", selectionType: .MultipleSelection)
form.last!.header = HeaderFooterView(title: "Branches")
form.last!.tag = "branch_section"
而不是
form +++= SelectableSection<ImageCheckRow<String>, String>("branch_section", selectionType: .MultipleSelection) { section in
section.header = HeaderFooterView(title: "Branches")
}
然后你的代码
let branch_section = self.form.sectionByTag("branch_section") as? SelectableSection<ImageCheckRow<String>, String>
print(branch_section)
print(branch_section.selectedRows())
将按照惯例运作,我希望这可以帮助你