Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I programmatically slide the UITableView down to reveal the underlying UIRefreshControl

Tags:

How can I reveal the UIRefreshControl when I update the table programmatically? Using [self.refreshControl beginRefreshing] make the spinner animate but does not reveal it.

like image 486
Dave Ronsom Avatar asked Dec 29 '12 13:12

Dave Ronsom


2 Answers

You'll have to manually change the contentOffset of your UITableView yourself. Be sure to account for the contentInset.top. It should be something as simple as:

CGPoint newOffset = CGPointMake(0, -[myTableView contentInset].top); [myTableView setContentOffset:newOffset animated:YES]; 
like image 63
Dave DeLong Avatar answered Nov 05 '22 17:11

Dave DeLong


This will do the trick

- (void)beginRefreshingTableView {      [self.refreshControl beginRefreshing];      // check if contentOffset is zero     if (fabsf(self.tableView.contentOffset.y) < FLT_EPSILON) {          [UIView animateWithDuration:0.25 delay:0 options:UIViewAnimationOptionBeginFromCurrentState animations:^(void){              self.tableView.contentOffset = CGPointMake(0, -self.refreshControl.frame.size.height);          } completion:^(BOOL finished){          }];      } } 
like image 23
Peter Lapisu Avatar answered Nov 05 '22 17:11

Peter Lapisu