UIRefreshControl( pull left to right refresh ) con

2019-07-23 09:20发布

问题:

I have a custom horizontal collection view that has 1 row and I want to add pull to refresh functionality which, by default, appears above my row of cells. I would like the user to be able to pull the collection view from left to right to activate the UIRefreshControl. Any ideas?

回答1:

For this you need to implement the UIScrollViewDelegate method

- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
     CGPoint offset = scrollView.contentOffset;
     CGRect bounds = scrollView.bounds;
     CGSize size = scrollView.contentSize;
     UIEdgeInsets inset = scrollView.contentInset;
     float y = offset.x + bounds.size.width - inset.right;
     float h = size.width;


    float reload_distance = 75; //distance for which you want to load more
    if(y > h + reload_distance) {
     // write your code getting the more data
       NSLog(@"load more rows");

    }

}



回答2:

Use this http://code4app.net/ios/RefreshView/5247b46b6803fa7304000000.it is used to refresh the view ,in the same manner u can refresh the collectionView.