【发布时间】:2017-10-22 19:46:11
【问题描述】:
我希望我的tableView 显示保存的数据。我试过但失败了。
我想在保存并重新打开视图后保留清单。
请帮我解决我的问题。
这是我的代码:
var id = [17,18,19]
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cellTheme: ThemeCell = self.tableView.dequeueReusableCell(withIdentifier: "cellTheme", for: indexPath) as! ThemeCell
cellTheme.themeLabel.text = listMenu[indexPath.row].theme
cellTheme.delegate = self
if id.isEmpty{
cellTheme.checkOutlet.image = UIImage(named: "ic_btn_home_checklist_off")
print("EMPTY")
}else{
for data in id{
print("TEST THEME \(id)")
print("DATA ! \(data)")
if listMenu[indexPath.row].id == data{
print("\(listMenu[indexPath.row].id) SAMA DENGAN DATA ")
cellTheme.checkOutlet.image = UIImage(named: "ic_btn_home_checklist_on")
}else{
print("\(listMenu[indexPath.row].id) TIDAK SAMA DENGAN DATA ")
cellTheme.checkOutlet.image = UIImage(named: "ic_btn_home_checklist_off")
}
}
}
return cellTheme
}
注意:listMenu[indexPath.row].id = [17, 18, 19, 146]
【问题讨论】:
标签: ios uitableview checkbox swift3 tableview