tableview trailingSwipeActionsConfigurationForRowAt crack in ios11

前端 未结 3 676
故里飘歌
故里飘歌 2021-01-19 01:23

I Use trailingSwipeActionsConfigurationForRowAt in IOS11 but when swipe multiple then app cracked.

func tableView(_ tableView: UITableView, trailingSwipeActi         


        
3条回答
  •  旧巷少年郎
    2021-01-19 01:37

    TL;DR - look if you are doing something with your data (e.g. reloading) between your swipes.


    I had similiar issue when I swipe-to-delete one cell (leaving it in edit mode - delete action visible) and then trying to swipe another caused that my app crashed. In my case it was because reloading table data in between those swipes.

    Swipe-to-delete gesture calls willBeginEditingRowAtIndexPath and didEndEditingRowAtIndexPath methods on UITableViewDelegate object. In the latter one I called tableView.reloadData(). When I swipe-to-delete other cell I got didEndEditingRowAtIndexPath method called for the first cell (also reloading data) and just after that system called willBeginEditingRowAtIndexPath for the other cell and the data was out of sync and UIKit crashes.

    When I removed the code that reloading data in didEndEditingRowAtIndexPath method my app won't crashes anymore :)

提交回复
热议问题