如何实施“加载另外25个"在UITableViewController中 [英] How to implement "Load 25 More" in UITableViewController
问题描述
我正在开发iPhone应用程序.应用程序将来自Web服务的大量记录加载到表视图控制器中.我想先加载25条记录,然后单击表视图末尾的再加载25条"之类的文件,以25条为一批.
I am working on an iphone application. Application loads plenty of records from a webservice into table view controller. I would like to load 25 records initially and remaining in 25 batch on clicking something like "Load 25 more" at the end of the table view.
任何帮助将不胜感激.
谢谢
推荐答案
只需在表页脚中放置一个与事件相关的按钮即可.单击该按钮后,将接下来的25个结果附加到您已经存在的项目数组中.
Just put a button connected to an Event in your table footer. When the button is clicked, append the next 25 results to your already existing array of items.
之后,只需执行[self.tableView setNeedsDisplay].我用它来让我的表知道表中有多余的数据.通过使用该选项,无需滚动到表格的右行,因为它保持了其原始位置.
After that, just do a [self.tableView setNeedsDisplay]. I use that to let my table know I have extra data in the table. By using that, there is no need to scroll to the right line in the table, because it keeps its original position.
此外,为什么要调用viewDidAppear方法,这在我看来似乎是错误的,因为(当然)视图已经出现,并且您在其中所做的所有整理和分配都已完成.只需将查看视图时以及将数据追加到一个单独的方法中时需要完成的工作,然后从button-press事件和viewDidAppear事件中调用该方法即可.
Also, why call the viewDidAppear method, this seems wrong to me, because (ofcourse) the view already appeared and all declerations and assignments you do there are re-done. Just put the stuff you need to be done while viewing the view AND when you are appending data in a seperate method and put call that method from your button-press event and from the viewDidAppear event.
这篇关于如何实施“加载另外25个"在UITableViewController中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!