【发布时间】:2018-03-05 11:35:05
【问题描述】:
我有一个应用程序,其中单击 tableview 单元格时,会加载另一个 tableview 并进行 api 调用。 Based on the response from api, table view list is loaded and when a particular item in the second tableview is selected, there is a selected checkbox displayed just besides the tableview text label and at the same time database is updated with selected value, 所以当我回到第一个表格视图时,我会显示一个带有所选项目的标签。
当我点击第一个表格视图单元格时,会调用 api 并将 api 的结果与数据库中的活动列表进行比较,并且该特定单元格应保持选中状态。
当在第一个 tableview 中选择了某些项目并且当我单击该特定单元格时,api 结果重新加载 tableview 并且不显示相应单元格的选择。
以下是代码:
for selectedDict in (appDelegate?.selectedCategoryFilterArray)! {
let selectedUuid = selectedDict.categoryUuid
print("selectedUuid\(selectedUuid)")
for allDict in self.requestedFiltersArray!{
let allUuid = allDict.objectForKey("uuid") as? String
if selectedUuid == allUuid {
cell.imgSelected.image = UIImage(named: "radio_selected")
continue
}else{
cell.imgSelected.image = UIImage(named: "radio")
}
print("allUuid\(allUuid)")
}
}
这没有按预期工作,没有单元格显示为选中状态,即使它们是选中的单元格。
【问题讨论】: