Is there any way to add a UIRefreshControl below a UITableView? I created a preview of what I want to achieve.
Asked
Active
Viewed 5,187 times
3
-
1There is already a good post available here http://stackoverflow.com/questions/14942460/uirefreshcontrol-at-the-bottom-of-the-uitableview-ios6 – Retro Dec 30 '13 at 10:53
1 Answers
17
These won't give the UIRefresh Controls but you can add these at the bottom of the Screen
Declare below in your header
UIActivityIndicatorView *spinner;
Initialise the same in ViewDidLoad in your implementation
spinner = [[[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray] autorelease];
[spinner stopAnimating];
spinner.hidesWhenStopped = NO;
spinner.frame = CGRectMake(0, 0, 320, 44);
self.tableviewName.tableFooterView = spinner;
Add These and it will be called when tableview Scrolled
- (void)scrollViewDidEndDragging:(UIScrollView *)aScrollView
willDecelerate:(BOOL)decelerate{
CGPoint offset = aScrollView.contentOffset;
CGRect bounds = aScrollView.bounds;
CGSize size = aScrollView.contentSize;
UIEdgeInsets inset = aScrollView.contentInset;
float y = offset.y + bounds.size.height - inset.bottom;
float h = size.height;
float reload_distance = 50;
if(y > h + reload_distance) {
NSLog(@"load more data");
[spinner startAnimating];
}
}
Hope This will help you out !

iDeveloper
- 498
- 4
- 9
-
good solution! I'm using this, with a little modifies: [spinner startAnimating]; spinner.hidesWhenStopped = YES; And I detect if I'm at the really end of the table view, and there [spinner stopAnimating]; – Magyar Miklós Feb 23 '14 at 09:39
-
solution is good but i have one query after hiding activity indicator table is not scrolled down . Please let me know if you have any solution for this too . – Alok Jun 18 '15 at 06:46