【问题标题】:UITableView won't display delete buttonUITableView 不会显示删除按钮
【发布时间】:2017-04-05 18:24:37
【问题描述】:

我已经实现了这些方法:

 func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool
  {
    return true
  }

  func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {

    if (editingStyle == UITableViewCellEditingStyle.delete) {
      showAlertToDeleteDevice()
    }
  }

并在其中设置断点,但这些函数没有回调。 -cellForRowAtIndexPath 和 -didSelectRowAtIndexPath 函数完美运行,这意味着数据源和委托连接一切正常。

可能是什么问题?因为我没有通过滑动看到删除按钮。同时我看到我的另一个表的删除按钮。

【问题讨论】:

标签: ios swift uitableview swift3 ios10


【解决方案1】:

你必须执行

func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]?

【讨论】:

    【解决方案2】:

    您使用了错误的功能。

    override func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool {
        return true
    }
    
    override func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
        if (editingStyle == UITableViewCellEditingStyle.Delete) {
            // delete action
        }
    }
    

    【讨论】:

      猜你喜欢
      • 2017-09-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-06-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多