Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to implement "Load 25 More" in UITableViewController

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.

Any help would be grealy appreciated.

Thanks

like image 628
Leo Avatar asked May 10 '10 07:05

Leo


2 Answers

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.

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.

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.

like image 89
Wim Haanstra Avatar answered Oct 20 '22 07:10

Wim Haanstra


I wrote an example project that does this which you can download from GitHub https://github.com/Abizern/PartialTable

like image 4
Abizern Avatar answered Oct 20 '22 09:10

Abizern