2016-02-28 70 views
2

我想为自定义单元格“删除附件”。 enter image description here如何添加删除附件到自定义单元格?

我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 
    } 

套装属性(但是,在删除附件??):

enter image description here

但是,这并不为我工作。

+1

它只在编辑模式下出现。 – tktsubota

+0

如何打开编辑模式?我认为'''canEditRowAtIndexPath'''这个方法可以做到这一点吗? – Arti

回答

2

为了获得编辑功能,您需要告诉表视图进行编辑。某处(可能是在为UIBarButtonItem一个动作):

tableView.setEditing(true, animated: true) 

为了消除编辑功能,你需要告诉表视图停止编辑。其他地方(可能在相同的动作):

tableView.setEditing(false, animated: true) 

注意editButtonItem()会自动建立此功能的UIBarButtonItem

相关问题