【发布时间】:2017-08-28 07:14:26
【问题描述】:
应该很简单,但我忘了。我是否需要在 delete 方法以及 cellForRowAt 中将单元格出列?
这是细胞:
class Row : UITableViewCell {
@IBOutlet weak var name: UILabel!
@IBOutlet weak var rating: UILabel!
@IBOutlet weak var address: UILabel!
@IBOutlet weak var status: UILabel!
}
删除方法如下:
override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
print(indexPath.row)
if (editingStyle == .delete) {
tableView.deleteRows(at: [indexPath], with: .automatic)
}
}
如何添加要删除的变量?我知道我不能简单输入例如:
name.remove(at: indexPath ) <-- or something like that. whats the cleanest method? Thanks
【问题讨论】:
-
Stream 你能解释一下你的问题吗?这里叫什么名字?
-
你必须先从dataSource数组中移除对象,然后使用
deleteRows
标签: ios uitableview swift3 xcode8