如何停止滑动删除功能在我的表格视图上点击两次?它通过尝试删除数据两次或访问已被删除的数据导致崩溃。轻扫滑动到删除被点击两次
实例删除功能,我说的是: http://media.tumblr.com/25eb2fcf7aa2cd84f5cb27c54ca1ad5b/tumblr_inline_muotqqEYrY1qzumo9.jpg
与该滑动删除功能的所有代码: http://pastebin.com/5VEbPvEC
这是代码删除:
//HTTP GET request to delete from server
//Then in:
DispatchQueue.main.async {
...
self.leaderboardData.remove(at: indexPath.row)
self.tableView.deleteRows(at: [indexPath], with: .fade)
}
编辑:我试着禁用用户交互以及:
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let cell = tableView.cellForRow(at: indexPath)
cell?.isUserInteractionEnabled = false
删除事件仍然被触发两次。
编辑2:
当我敲击两次,我不是得到这个崩溃:
libswiftFoundation.dylib`static Foundation.IndexPath._unconditionallyBridgeFromObjectiveC (Swift.Optional<__ObjC.NSIndexPath>) -> Foundation.IndexPath:
0x100c72914 <+0>: stp x20, x19, [sp, #-32]!
0x100c72918 <+4>: stp x29, x30, [sp, #16]
0x100c7291c <+8>: add x29, sp, #16 ; =16
0x100c72920 <+12>: mov x19, x0
0x100c72924 <+16>: cbz x19, 0x100c7294c ; <+56>
0x100c72928 <+20>: mov x0, x19
0x100c7292c <+24>: bl 0x100c9ae14 ; function signature specialization <Arg[0] = Owned To Guaranteed, Arg[1] = Dead> of Foundation.IndexPath.init (nsIndexPath : __ObjC.NSIndexPath) -> Foundation.IndexPath
0x100c72930 <+28>: mov x20, x0
0x100c72934 <+32>: mov x0, x19
0x100c72938 <+36>: bl 0x100cdc2e4 ; symbol stub for: objc_release
0x100c7293c <+40>: mov x0, x20
0x100c72940 <+44>: ldp x29, x30, [sp, #16]
0x100c72944 <+48>: ldp x20, x19, [sp], #32
0x100c72948 <+52>: ret
-> 0x100c7294c <+56>: brk #0x1
或者我看到了其中的一些:
/api/leaderboards/delete/132 returned 500.
500表明,它未能因为没有记录而删除记录。
这只发生在我混合出现的删除按钮时。
编辑3:
我已经改变了我的代码一点,现在捣碎删除按钮是不是导致飞机坠毁,但每当我删除了最后一排,我得到一个崩溃。
代码: http://pastebin.com/57hMZQiJ
断点处被触发线:
self.tableView.deleteRows(at: [indexPath], with: .fade)
*** Assertion failure in -[UITableView _endCellAnimationsWithContext:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3600.5.2/UITableView.m:1610
感谢。
将代码也在这里。 – KKRocks
你想看什么代码?没有具体的东西。它是一个默认的UITableView。 – toast
想要查看您的代码以进行删除。 – KKRocks