【问题标题】:Using swipe gesture to edit table view cells in swift3使用滑动手势在 swift3 中编辑表格视图单元格
【发布时间】:2017-04-03 00:19:08
【问题描述】:

如何使用 Swip 手势对每个表格视图单元格执行“编辑”和“删除”操作?类似于电子邮件应用程序!有什么建议吗?

【问题讨论】:

    标签: swift3 tableviewcell swipe-gesture


    【解决方案1】:
    func tableView(_ tableView: UITableView, canEditRowAt indexPath: 
    IndexPath) -> Bool {
      // Return NO if you do not want the specified item to be editable.
      return true
    }
    // Override to support editing the table view.
    
       func tableView(_ tableView: UITableView, commitEditingStyle 
       editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: 
      IndexPath) {
       if editingStyle == .delete {
            // Delete the row from the data source
            tableView.deleteRows(at: [indexPath], with: .fade)
       }
      else if editingStyle == .insert {
          // Create a new instance of the appropriate class, insert it 
             into the array, and add a new row to the table view
       }
    
    }
    

    【讨论】:

      猜你喜欢
      • 2019-02-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-03-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多