我想在“通讯录”应用中做类似的事情:
标准模式有一些单元格 和其他编辑模式。 我试过的是:
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
if self.editing{
let cell = tableView.dequeueReusableCellWithIdentifier(TextFieldCellIdentifier, forIndexPath: indexPath) as TextFieldTableViewCell
return cell
}else{
let cell = tableView.dequeueReusableCellWithIdentifier(ButtonCellIdentifier, forIndexPath: indexPath) as ButtonTableViewCell
return cell
}
}
我应该在何处以及如何触发重新加载的单元格?
答案 0 :(得分:2)
听起来您希望在用户进入或离开编辑模式时,表格视图单元格可以重新加载到单元格的相应编辑/非编辑版本。如果我理解正确,那么你可以为编辑属性提供一个setter,以便在编辑模式改变时重新加载表视图单元格。
override func setEditing(editing: Bool, animated: Bool) {
tableView.reloadData()
self.tableView.beginUpdates()
super.setEditing(editing, animated: animated)
self.tableView.endUpdates()
}