无法在iOS 13中使用可扩散数据源滑动以使用Tableview删除 [英] Unable to swipe to delete with tableview using diffable data source in iOS 13

查看:59
本文介绍了无法在iOS 13中使用可扩散数据源滑动以使用Tableview删除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在更新 UITableViewController 以使用新的 UITableViewDiffableDataSource ,我可以执行所有操作,但要滑动即可删除.

I'm updating a UITableViewController to use the new UITableViewDiffableDataSource, I have everything working except Swipe to delete.

这是我如何使用滑动删除操作的示例

This is an example of how I use swipe to delete

func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {

   let lockedAction = UIContextualAction(style: .normal, title: "TEST") { (_, _, completion) in
       print("tapped....")
       completion(true)
   }

    return UISwipeActionsConfiguration(actions: [lockedAction])
}

但这在具有 UITableViewDiffableDataSource

没有滑动,方法中的断点也不会被调用

There is no swipe, a break point within the method is never called either

我以为这是一个Beta错误,但是我更新到了Xcode 11 GM,并且发生了同样的事情.

I thought this was a beta bug, but I updated to Xcode 11 GM and that same thing is occurring.

谢谢您的建议

推荐答案

您应该将 UITableViewDiffableDataSource 子类化,并为要在其中启用此功能的行返回 true :

You should subclass UITableViewDiffableDataSource and return true for the rows you want to enable this for in:

override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool

这篇关于无法在iOS 13中使用可扩散数据源滑动以使用Tableview删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆