[英]tableView still shows two rows even though I deleted one from the data source and reloaded the table
I have an NSMutableArray _conversationsArray that basically stores IDs of all the conversations a user has in my app. 我有一个NSMutableArray _conversationsArray,它基本上存储用户在我的应用程序中进行的所有对话的ID。 Based on that value I show different number of rows in the tableView.
基于该值,我在tableView中显示了不同的行数。 When I delete a conversation from the data source and trigger reload of the tableView,
numberOfRowsInSection
method triggers and by setting a breakpoint I check the number of elements (conversations) in that array: 当我从数据源中删除对话并触发tableView的重新加载时,
numberOfRowsInSection
方法会触发并通过设置断点来检查该数组中元素(对话)的数量:
Everything seems to be fine, the result is one object which is great because I had two of them before the deletion. 一切似乎都很好,结果是一个对象很棒,因为删除之前我有两个对象。 The problem is, as you can see on the far left of the screen, both rows are still visible in the tableView (even after the breakpoint) :/ The second row should have disappeared but it didn't.
问题是,正如您在屏幕最左侧看到的那样,两行在tableView中仍然可见(即使在断点之后):/第二行应该消失了,但是没有。 It did become unresponsive to touch events, but I need it gone.
它确实变得对触摸事件没有反应,但是我需要它消失了。
Have you ever experienced a problem like this? 您是否遇到过这样的问题? Any help would be greatly appreciated.
任何帮助将不胜感激。
--- Update --- -更新-
Could it be that it has to do something with the threads? 可能是它必须对线程进行某些处理吗? because it seems that the table updates as it should when the thread changes :/ I might be wrong about it as it's hard to debug
因为似乎表在线程更改时会按需更新://我可能错了,因为它很难调试
It looks like you're not reloading the table view on the main thread, since -tableView:numberOfRowsInSection is called on a background thread (?). 似乎您没有在主线程上重新加载表视图,因为-tableView:numberOfRowsInSection在后台线程(?)上被调用。 In UIKit -reloadData must be called on the main thread.
在UIKit中-reloadData必须在主线程上调用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.