首页 文章

如何在tableview中选择多个选项并保存?如果我向后移动,我想看看之前选择的内容并进行更改

提问于
浏览
0

在Swift 3中,如何在tableview中选择多个选项并保存?如果我搬回去,我想看看我之前选择的并改变它!我正在使用“didSelectRowAt IndexPath”和“didDeselectRowAt IndexPath” .

当我打开tableview并选择行时,一切正常 . 我可以做出选择并转到下一个ViewController . 但当我回到TableView时,我没有看到我选择的行,也无法改变我的选择 .

1 回答

  • 0

    您可以将tableviewcell的索引路径存储在一个数组中,迭代它,获取UITableViewCell实例将附件类型设置为复选标记 .

    for index in indexpaths {
     let cell = table.cellForRow(at: index)
     cell?.accessoryType = .checkmark
     //For selecting rows of already selected one
     tablView.selectRow(at: indexPath, animated: true, scrollPosition: 
     .bottom)
    }
    

    注意: - 如果要允许多个选择,请设置tableView.allowsMultipleSelection = true .

相关问题