通过标​​签获取SelectableSection

通过标​​签获取SelectableSection

我有这个密码:

    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

最佳答案

为了做到这一点,你需要用这个

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

我希望这对你有帮助

关于ios - Eureka 通过标​​签获取SelectableSection,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/37680383/

10-09 02:32