我不确定下面的代码有什么问题。我所做的只是获取表格中的所有行并将其标记为选中状态,如果它们已被选中,则取消选择它们。每当我尝试这个时,一些行索引路径是不正确的。总是有几条索引路径每次都错过。我究竟做错了什么?多重选择IOS
let visibleRows = self.tableView.indexPathsForVisibleRows
for row in visibleRows! {
if(self.sections[row.section].files[row.row].type != "cloud"){
let cell = self.tableView.cellForRowAtIndexPath(row)
cell?.setSelected(action, animated: true)
tableView.selectRowAtIndexPath(row, animated: true, scrollPosition: UITableViewScrollPosition.Top)
if(action == true){
cell?.accessoryType = .Checkmark
} else {
cell?.accessoryType = .None
NSNotificationCenter.defaultCenter().postNotificationName("disableOptions", object: nil)
}
}
}
你确定你得到所有的行?您的代码是为VisibleRows编写的。 – Wolverine