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

后端 未结 4 1855
天涯浪人
天涯浪人 2021-02-04 01:06

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.

4条回答
  •  走了就别回头了
    2021-02-04 01:33

    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){
    
            }];
    
        }
    }
    

提交回复
热议问题