Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
tableview跟踪操作ios11中Rowat裂纹的配置_Tableview_Ios11 - Fatal编程技术网

tableview跟踪操作ios11中Rowat裂纹的配置

tableview跟踪操作ios11中Rowat裂纹的配置,tableview,ios11,Tableview,Ios11,我在IOS11中使用了trailingswipeactions对rowat的配置,但当多次滑动时,应用程序就会崩溃 func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? { let delete = UIContextualAction(style: .normal

我在IOS11中使用了trailingswipeactions对rowat的配置,但当多次滑动时,应用程序就会崩溃

func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
    let delete = UIContextualAction(style: .normal, title: "Delete") { action, view, completionHandler in
      print("Deleting!")
      completionHandler(false)
    }
    delete.backgroundColor = UIColor.red
    let config = UISwipeActionsConfiguration(actions: [delete])
    config.performsFirstActionWithFullSwipe = false
    return config
  }
还有一些错误

 *** Assertion failure in -[UISwipeActionController swipeHandlerDidBeginSwipe:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3694.4.18/SwipeActions/UISwipeActionController.m:268
 *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'No occurrence for index path (null)'

TL;DR-查看您是否在刷卡之间对数据进行处理(例如重新加载)


我有类似的问题,当我刷卡删除一个单元格(保持编辑模式-删除操作可见),然后试图刷卡另一个导致我的应用程序崩溃。在我的例子中,这是因为在这些滑动之间重新加载表数据

滑动以删除
UITableViewDelegate
对象上的手势调用
willBeginEditingRowAtIndexPath
dideneditingrowatindexpath
方法。在后者中,我调用了
tableView.reloadData()
。当我滑动以删除另一个单元格时,我得到了为第一个单元格调用的
didEndEditingRowAtIndexPath
方法(也重新加载数据),紧接着为另一个单元格调用的系统
willBeginEditingRowAtIndexPath
,数据不同步,UIKit崩溃

当我删除在
didEndEditingRowAtIndexPath
方法中重新加载数据的代码时,我的应用程序将不再崩溃:)

您需要实现

作为最小值,返回空数组,但不是
nil

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

我只是使用UIViewController+UITableViewDataSource和UITableViewDelegate组合,而不是使用UITableViewController解决刷卡问题。

找到解决方案了吗?它删除了TableViewFryi的刷卡功能。我尝试了这个,但没有解决我的崩溃问题。(我认为有几种方法可以触发这个问题,如果我能缩小对代码路径的更好描述,我将创建一个特定的问题并发布它。)