Add activity indicator at bottom of UITableView?

I have a UITableview , how will I first get 20 objects from the server and fill in the UITableView then when it reaches the last line, I need to make another service call to get the next 20 objects.

My problem is that I need to add an activity indicator at the bottom of the table and say “Download”. The user can scroll up to view current objects, but should not scroll down.

Is there any user control? Is there a better way to achieve this?

Thanks in advance.

+9
ios objective-c uitableview uiactivityindicatorview
source share
2 answers

Let try the TableView Footer View to show an activity indicator.

For example:

Declare UIView * footerView; in .h file

Add the following methods to the file.m

  - (void)viewDidLoad { [super viewDidLoad]; [self initFooterView]; } -(void)initFooterView { footerView = [[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, 320.0, 40.0)]; UIActivityIndicatorView * actInd = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray]; actInd.tag = 10; actInd.frame = CGRectMake(150.0, 5.0, 20.0, 20.0); actInd.hidesWhenStopped = YES; [footerView addSubview:actInd]; actInd = nil; } -(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView { BOOL endOfTable = (scrollView.contentOffset.y >= ((self.contentArray.count * 40) - scrollView.frame.size.height)); // Here 40 is row height if (self.hasMoreData && endOfTable && !self.isLoading && !scrollView.dragging && !scrollView.decelerating) { self.tableView.tableFooterView = footerView; [(UIActivityIndicatorView *)[footerView viewWithTag:10] startAnimating]; } } 

Thanks!

+27
source share

check out this open source project. May help you ...

https://github.com/dkSolutions/DKPaginatedTableView

+2
source share

All Articles