Automatically load data when scrolling in ios app

I am trying to do the following in my application:

I got my data from an online server and I put it in cells. I need automatic data loading when scrolling down, for example, 10 cells are loaded when the application is running, and then when I scroll down 10 other cells are dynamically loaded.

As in the following example:

enter image description here

Thanks for the advance,

+4
source share
5 answers

You can implement this method inside your view controller and get the following entry

-(void)scrollViewDidScroll:(UIScrollView *)scrollView{ if (([scrollView contentOffset].y + scrollView.frame.size.height) >= [scrollView contentSize].height){ // Get new record from here } } 

This is the easiest way to implement paging. if you want to add an activity indicator at the bottom, you can add it inside the same function.

+6
source

This automatically loads the following piece of data when the user scrolls to the bottom:

 #pragma mark - UIScrollViewDelegate - (void)scrollViewDidScroll:(UIScrollView *)scrollView { if (scrollView.contentSize.height - scrollView.contentOffset.y - scrollView.frame.size.height < 60) { [self loadRequest]; } } 
+4
source

Try the following:

STableViewController

STableViewController is best suited for Load More and Pull for Update.

+2
source

For iOS 6.0, there is a standard control called UIRefreshControl in sdk. apple doc here

and so on - this is a step-by-step tutorial here .

Another open source library is available.

+1
source

To do this, you can use the following method:

 - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath { //put data on your array [tableView reloadData]; } 

For a better understanding see this

You will also get the source code here.

Hope this helps.

0
source

All Articles