UITableView Drawing Problems When ReloadData Is Called(调用 ReloadData 时 UITableView 绘制问题)
问题描述
我有一个非常大的项目"列表(最多 250 个条目),并且不断变化.该列表正在 UITableView 中显示.
我有一个轮询线程,它将下载一些新条目并将它们插入 SQLite DB.
当新条目到达时,我调用我的表视图数据源对象来更新它的数据集,它运行一个 SQL 查询并返回一个新的条目数组.
完成后,我在表格视图上调用 -reloadData.发生这种情况时,在 10 种情况下大约有 7 种情况下,表格视图绘制为空白(不显示单元格,只有表格的背景颜色可见),直到进行后续的 -reloadData 调用.触摸表格视图(滚动、选择单元格、任何会强制重绘的内容)将使其重新出现.
表格视图、它的 IBOutlet 指针和当前显示的单元格在我看到空白绘图错误时都是有效的,所以我相当有信心它们没有被释放.
这几天我一直在尝试调试它,但它真的开始让我陷入困境.
在这方面的任何帮助都会非常棒,谢谢.
如果你做一个 [ myTable performSelectorOnMainThread:@selector(reloadData) withObject:nil waitUntilDone:NO] 会有帮助吗?
p>
如果您不从主线程操作您的 GUI 更新,则可能会出现您提到的问题.
I have a pretty large list of 'items' (up to 250 entries) which is constantly changing. The list is being displayed in a UITableView.
I have a polling thread that will download some new entries and insert them into a SQLite DB.
When new entries have arrived, I call to my table view data source object to update its data set, which runs a SQL query and returns a new array of entries.
After this is complete, I call -reloadData on the table view. When this happens, in about 7 out of 10 cases, the table view draws blank (no cells are displayed and only the background colour of the table is visible) until a subsequent -reloadData call is made. Touching the table view (scrolling, selecting a cell, anything that will force a redraw) will make it reappear.
The table view, its IBOutlet pointer and it's currently displayed cells are all valid at the times I see the blank drawing bug, so I'm fairly confident that they're not being released.
I've been trying to debug this for a few days now and it's really beginning to drive me up the wall.
Any help on this would be freaking awesome, thanks.
Will it help if you do a [ myTable performSelectorOnMainThread:@selector(reloadData) withObject:nil waitUntilDone:NO]
?
The problem you mentioned can arise if you do not action your GUI updates from the main thread.
这篇关于调用 ReloadData 时 UITableView 绘制问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:调用 ReloadData 时 UITableView 绘制问题


- Android viewpager检测滑动超出范围 2022-01-01
- Android - 拆分 Drawable 2022-01-01
- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01
- android 4中的android RadioButton问题 2022-01-01
- 用 Swift 实现 UITextFieldDelegate 2022-01-01
- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01
- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01
- 想使用ViewPager,无法识别android.support.*? 2022-01-01