Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
543 views
in Technique[技术] by (71.8m points)

iphone - 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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...