简体   繁体   English

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

[英]how to automatically slide/swipe the cell tableviewcell swift 3

how to automatically slide the cell when we touch button like adding contact? 当我们触摸按钮时如何自动滑动单元格,如添加联系人? is there any delegate for that? 那有代表吗?

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

You should implement delegate method - commitEditingStyle and you will be done!! 你应该实现delegate方法 - commitEditingStyle ,你将完成!

something like, 就像是,

   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()
    }
}

And you can do on button's click, 你可以按下按钮,

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

to show (-) sign on every cells ! 在每个细胞上显示( - )标志!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用滑动动作使用动画移动tableViewCell中的单元格 - How to move cell in tableViewCell with animation with usage of swipe action 如何在 Swift 中滑开/滑入侧边菜单? - How to Swipe Away / Slide In a Side Menu In Swift? Swift 3-如何滑动删除表格视图单元格? - swift 3 - how to swipe remove table view cell? Swift:单元格TableviewCell中的手势不起作用 - Swift: Gesture in cell TableviewCell not working 如何在Swift 4中点击单元格时可视化tableViewCell中的更改 - How to visualise changes in tableViewCell when tapped on cell in Swift 4 如何在自定义单元格中切换切换时调用函数-TableViewCell Swift - How to call a function on toggle of switch in a custom cell - TableViewCell Swift iOS Swift,如何删除TableViewCell中的UIView并调整单元格高度? - iOS Swift, how to delete a UIView in a TableViewCell and adjustment cell height? Swift。如何在TableViewCell中为每个单元格编辑两个不同的label? - Swift. How to edit two different label in TableViewCell for each cell? Swift-如果检测到“滑动删除”,如何在自定义tableViewCell类中隐藏按钮? - Swift - How to hide button in custom tableViewCell class if left “Swipe to delete” detected? 如何在Swift 2中的另一个ViewController中滑动删除Core Data TableViewCell(带行动作) - How to swipe to delete Core Data TableViewCell (with row action) in another ViewController in Swift 2
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM