UITableView cellForRowAtIndexPath 偶尔不被调用?

发布于 2024-09-02 10:41:57 字数 575 浏览 4 评论 0原文

我正在开发一个图形应用程序,它在主导航/选项卡视图上显示一个使用 openGL 渲染图形的 UIView。该视图下方是一个 UITableView,它显示图表上的元素列表和一个添加按钮。

有时,当用户单击另一个选项卡,然后返回到图形视图选项卡时,表视图不会重新绘制。

我在导航控制器(也是表视图的委托和数据源)viewDidAppear 方法中调用了一个 [tableView reloadData] 方法。

numberOfSectionsInTableView 和 numberOfRowsInSection 被调用,但 cellForRowAtIndexPath 不会被调用,尽管后两种方法都返回正值。

这是一个间歇性问题,仅在某些时候发生,但尚不清楚是什么(如果有的话)影响此问题。

有人有什么想法吗?

[编辑] 应该快速添加;单击或以其他方式与表视图交互,无论是否出现所描述的错误,总是会导致其成功重绘。

[再次]更多信息;当它按照描述发生故障,并且调用前两个方法但不调用 cellforRowetc 方法时,似乎要等到用户与表交互,然后才最终调用 cellForRowetc(然后不调用前两个方法)并重绘。

I'm developing a graphing application that on the main navigation/tab view displays a UIView that renders a graph using openGL. Beneath that view is a UITableView that displays the list of elements on the graph, and an add button.

Occasionally, when the user clicks on another tab, and then returns to the graph view tab, the table view does not get redrawn.

I have a [tableView reloadData] method being called in the navigation controllers' (also the table view's delegate and data source) viewDidAppear method.

numberOfSectionsInTableView and numberOfRowsInSection get called, but cellForRowAtIndexPath does not despite both latter methods returning positive values.

This is an intermittant problem, only happening some of the time, but it's not clear what (if anything) influences this.

Does anyone have any ideas?

[edit] Should just quickly add; clicking or otherwise interacting with the table view, whether faulted as described or not, ALWAYS causes it to be sucessfully redrawn.

[And again] A bit more information; when it faults as described, and calls the first two but not the cellforRowetc method, it seems to wait until the user interacts with the table before cellForRowetc is finally called (the first two methods are then not called) and is redrawn.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

晨与橙与城 2024-09-09 10:41:57

我有一个 UIActivityIndi​​cator,在一个单独的线程上启动,显示何时向 Web 服务发出请求。当 Web 服务调用完成时,会向图形控制器类发送通知以停止并隐藏 UIActivityIndi​​cator。在此方法中,无论视图是否可见,都会在表上调用 reloadData,这似乎导致了问题。

结论似乎是不要在表上调用 reloadData ,除非它是可见的。

I had a UIActivityIndicator, started on a seperate thread, that showed when requests were being made to a web service. When the web service calls were completed, a notification was sent to the graph controller class to stop and hide the UIActivityIndicator. In this method, reloadData was being called on the table whether the view was visible or not, which seemed to be causing the problem.

The conclusion seems to be not to call reloadData on a table unless it's visible.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文