【发布时间】:2017-03-02 14:55:44
【问题描述】:
我的 iOS 应用使用 UITableViewController 来显示表格视图。内置编辑按钮切换到编辑模式。一些单元格需要显示一个附属视图,这是通过设置cell.accessoryType = .detailButton 来完成的。同时在所有单元格上设置cell.editingAccessoryType = .none。在编辑模式下,单元格还会显示重新排序、删除和插入附件视图。
问题
问题是当切换到编辑模式时,附件视图停留在某些单元格上,并移动到单元格的左上角。这似乎是随机发生的。
下面是配置每个单元格的代码:
private func tableView(_ tableView: UITableView, cellForTextFragment fragment: Fragment, at indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: basicCellIdentifier, for: indexPath) as! BasicFragmentCell
cell.contentTextField.text = fragment.value
cell.showsReorderControl = true
switch fragment.type {
case .phoneNumber, .email:
cell.accessoryType = .detailButton
default:
cell.accessoryType = .none
}
cell.editingAccessoryType = .none
return cell
}
完整源码在 GitHub 上:https://github.com/lukevanin/OCRAI
编辑模式
非编辑模式
【问题讨论】:
标签: ios uitableview