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 绘制问题
基础教程推荐
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01