0

我有这个代码:

    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

4

1 回答 1

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())

会按预期工作,我希望这对你有帮助

于 2016-06-22T18:21:32.903 回答