如何自动滑动/滑动单元格tableviewcell swift 3

时间:2016-09-28 05:14:12

标签: ios swift uitableview tableviewcell

当我们触摸按钮时如何自动滑动单元格,如添加联系人?是否有任何代表?

when we clicked the delete button, cell automatically slide

1 个答案:

答案 0 :(得分:5)

您应该实施delegate方法 - commitEditingStyle,您将完成!!

之类的,

   func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath)
{

    // below code will delete one row - you can mange another kind of deletion here like delete from database also
    if editingStyle == .Delete
    {
        yourDataArray.removeAtIndex(indexPath.row)
        self.yourTableView.reloadData()
    }
}

你可以按下按钮,

   self.yourTableView.setEditing(true, animated: true)

在每个单元格上显示( - )符号!