简体   繁体   English

UITableView cellForRowAtIndexPath偶尔不调用?

[英]UITableView cellForRowAtIndexPath occasionally not called?

I'm developing a graphing application that on the main navigation/tab view displays a UIView that renders a graph using openGL. 我正在开发一个绘图应用程序,该应用程序在主导航/选项卡视图上显示一个UIView,该UIView使用openGL渲染图形。 Beneath that view is a UITableView that displays the list of elements on the graph, and an add button. 在该视图下面是一个UITableView,它显示图形上的元素列表以及一个添加按钮。

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. 我在导航控制器(也是表视图的委托和数据源)的viewDidAppear方法中调用了[tableView reloadData]方法。

numberOfSectionsInTableView and numberOfRowsInSection get called, but cellForRowAtIndexPath does not despite both latter methods returning positive values. 尽管调用了numberOfSectionsInTableView和numberOfRowsInSection,但cellForRowAtIndexPath却没有,尽管后两种方法都返回正值。

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; [edit]应该快速添加; 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. 当它如上所述发生故障并调用前两个方法但不调用cellforRowetc方法时,似乎要等到用户与表进行交互之后,才最终调用cellForRowetc(然后不调用前两个方法)并重新绘制。

I had a UIActivityIndicator, started on a seperate thread, that showed when requests were being made to a web service. 我有一个UIActivityIndi​​cator,它从一个单独的线程启动,显示何时向Web服务发出请求。 When the web service calls were completed, a notification was sent to the graph controller class to stop and hide the UIActivityIndicator. Web服务调用完成后,通知被发送到图形控制器类,以停止并隐藏UIActivityIndi​​cator。 In this method, reloadData was being called on the table whether the view was visible or not, which seemed to be causing the problem. 在此方法中,无论视图是否可见,都在表上调用reloadData,这似乎是造成问题的原因。

The conclusion seems to be not to call reloadData on a table unless it's visible. 结论似乎是除非在表上可见,否则不要在表上调用reloadData。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 UITableView tableView:cellForRowAtIndexPath:没有被调用 - UITableView tableView:cellForRowAtIndexPath: not getting called uitableview cellforrowatindexpath未调用,但没有:调用section中的行 - uitableview cellforrowatindexpath not called but no:of rows in section is called UITableView:`tableView:cellForRowAtIndexPath:`并非对所有行都调用 - UITableView: `tableView:cellForRowAtIndexPath:` not called for all rows 即使正确调用了cellForRowAtIndexPath,UITableView也会显示空白单元格 - UITableView shows blank cells even when cellForRowAtIndexPath is called properly 内存不足警告后未调用UITableView的cellForRowAtIndexPath - UITableView's cellForRowAtIndexPath is not getting called after low memory warning 目标 C:UITableView:在 iPhone 中调用 cellForRowAtIndexPath 但在 iPad 中失败 - Objective C : UITableView : cellForRowAtIndexPath being called in iPhone but fails in iPad cellForRowAtIndexPath:未调用 - cellForRowAtIndexPath: not called UITableView reloadData - 未触发cellForRowAtIndexPath - UITableView reloadData - cellForRowAtIndexPath not fired UITableView有关cellForRowAtIndexPath的问题 - UITableView Problems with cellForRowAtIndexPath 带有NSManagedObjects的UITableView cellForRowAtIndexPath的问题 - Issue with UITableView cellForRowAtIndexPath with NSManagedObjects
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM