简体   繁体   English

即使我从数据源中删除了一行并重新加载了表格,tableView仍然显示两行

[英]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.

相关问题 当我从领域中删除一个对象时,如何隐式重新加载 tableview? - How is tableview implicitly reloaded when I deleted an object from realm? 即使数据仍在从 Cloud Firestore 加载,方法仍会继续 - Method continues even though data is still loading from Cloud Firestore 带有自定义图像的 UIButton 仍然显示 titleLabel,即使我将其设置为空白 - Swift iOS - UIButton with custom image still shows titleLabel even though I set it to blank - Swift iOS 具有数据的两个表视图,并且要从一个特定的表视图中删除索引。 我也必须删除另一个阵列吗? - Two table views with data and want to delete a index from one specific tableview. Do I have to delete the other array also? Tableview 需要重新加载两次才能更新文本字段中的数据? - Tableview need to be reloaded twice to update the data from textfield? 我如何知道何时可以重新加载表视图,以便它显示我已下载和解析的 JSON 数据? - How do I tell when the table view can be reloaded so that it shows JSON data I've downloaded and parsed? TableView即使识别输入也不会更新数据? - TableView isn't updating data even though it recognizes input? 即使我从捆绑软件中删除了图像,为什么Xcode仍会将图像复制到设备上? - Why would Xcode still copies images to device even though I removed them from bundle? 如何从Swift 2的tableView中清除已删除的表格视图单元格 - How do I clear a deleted table view cell from a tableView in swift 2 删除从节中删除的所有行后出现的Tableview部分 - Tableview section appearing after deleting all rows deleted from section
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM