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

Ald*_*rdi 4 uitableview tableviewcell ios swift

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

当我们点击删除按钮时,单元格会自动滑动

Lio*_*ion 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()
    }
}
Run Code Online (Sandbox Code Playgroud)

你可以按下按钮,

   self.yourTableView.setEditing(true, animated: true)
Run Code Online (Sandbox Code Playgroud)

在每个细胞上显示( - )标志!