如何添加删除附件到自定义单元格?
问题描述:
我想为自定义单元格“删除附件”。 如何添加删除附件到自定义单元格?
我overrided canEditRowAtIndexPath
方法:这里
// Override to support conditional editing of the table view.
override func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool {
// Return false if you do not want the specified item to be editable.
return true
}
套装属性(但是,在删除附件??):
但是,这并不为我工作。
答
为了获得编辑功能,您需要告诉表视图进行编辑。某处(可能是在为UIBarButtonItem
一个动作):
tableView.setEditing(true, animated: true)
为了消除编辑功能,你需要告诉表视图停止编辑。其他地方(可能在相同的动作):
tableView.setEditing(false, animated: true)
注意editButtonItem()
会自动建立此功能的UIBarButtonItem
。
它只在编辑模式下出现。 – tktsubota
如何打开编辑模式?我认为'''canEditRowAtIndexPath'''这个方法可以做到这一点吗? – Arti