tableView:canEditRowAtIndexPath: crash when popping viewController

前端 未结 4 1172
暗喜
暗喜 2021-01-30 13:29

I have a viewController with a UITableView, the rows of which I allow to edit (delete) with a swipe - much like in the Mail app. I do it with, among other, this met

4条回答
  •  鱼传尺愫
    2021-01-30 14:08

    I know this is an old post, but I recently had this problem, and thought others might benefit from what I found: I am using Xcode 9 and iOS 11, and I am employing the new method of using a SearchController. If I clicked the system back button while I was searching, I got the fatal on tableView(_: canEditRowAt indexPath:). Changing setEditing to false did not solve my issue. The problem was that I returned true/false in my canEditRowAt override depending upon if my data source had records, but when I was searching, I had a different data source (a filtering array). Once I checked against the right data source, the back button worked.

提交回复
热议问题