iOS Monster
iOS Monster

Reputation: 2119

How t add new rows atomatically, on scrolling the table view

I want to make an application in which I need a functionality of automatic addition on new rows to the table view. say at first the table view has 5 rows in it, after that when I scroll the table then more 5 rows should be added to the end of the table.

please help me!!!!

Upvotes: 0

Views: 534

Answers (2)

iOS Monster
iOS Monster

Reputation: 2119

Hey!! You can try the idea as implemented on following post

http://iphoneappmonster.blogspot.com/2011/04/insert-rows-to-table-view-on-click-of.html

Upvotes: 1

Philippe
Philippe

Reputation: 925

The way you would do this is to implement tableView:willDisplayCell:forRowAtIndexPath in your UITableViewDelegate, and watch for the last row being displayed (using the indexPath argument).

When the last row is about to be displayed, set a flag and call -reloadData on your UITableView. This will force the table view's recalculation, and call your datasource where you should see the flag and add (say) 5 rows to the previous total number of rows (and also clear the flag).

Now, the row that will display will no longer be the last row (it will have 5 rows below it) and presto! Infinitely-scrolling table view.

Keeping track of the total number of rows (and their content) is left as an exercise for the reader.

Upvotes: 0

Related Questions