Uirefreshcontrol on Uicollectionview Only Works If the Collection Fills the Height of the Container

UIRefreshControl on UICollectionView only works if the collection fills the height of the container

Try this:

self.collectionView.alwaysBounceVertical = YES;

Complete code for a UIRefreshControl

UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init];
refreshControl.tintColor = [UIColor grayColor];
[refreshControl addTarget:self action:@selector(refershControlAction) forControlEvents:UIControlEventValueChanged];
[self.collectionView addSubview:refreshControl];
self.collectionView.alwaysBounceVertical = YES;

UIRefreshControl with low height UICollectionView

You can implement scrollViewDidScroll.
If the scrollView's contentOffset is past a certain point, then implement your refresh programmatically using beginRefreshing()

eg (with the refresh control connected to an outlet named 'refreshControl')

func scrollViewDidScroll(scrollView: UIScrollView) {

let currentOffset = scrollView.contentOffset

let yOffset = currentOffset.y

if yOffset < -30.0 && !refreshControl.refreshing {
refreshControl.beginRefreshing()
}
}

don't forget to set the scrollView's delegate to self if you haven't already

edit: sorry it's beginRefreshing(), not startRefreshing().

UIRefreshControl on UICollectionView with height very low

This instance, you don't need use @selector. You can use delegate of UIScrollView. You override function - (void)scrollViewDidScroll:(UIScrollView *)scrollView

This is my code:

- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
if (scrollView.contentOffset.y < -65 && ![refreshControl isRefreshing]) {
[refreshControl beginRefreshing];
//do all the work

[refreshControl endRefreshing];
}
}

UIRefreshControl appears on top of collection view items instead of behind

The way I figure this out is to change the refreshControll zPosition to be behind every view with the following:

refreshControl.layer.zPosition = -1

Hope this helps anyone further.

UIRefreshControl with UICollectionView in iOS7

Having the same problem and found a workaround that seems to fix it.

This seems to be happening because the UIScrollView is slowing down the tracking of the pan gesture when you pull past the edge of the scrollview. However, UIScrollView is not accounting for changes to contentInset during tracking. UIRefreshControl changes contentInset when it activates, and this change is causing the jump.

Overriding setContentInset on your UICollectionView and accounting for this case seems to help:

- (void)setContentInset:(UIEdgeInsets)contentInset {
if (self.tracking) {
CGFloat diff = contentInset.top - self.contentInset.top;
CGPoint translation = [self.panGestureRecognizer translationInView:self];
translation.y -= diff * 3.0 / 2.0;
[self.panGestureRecognizer setTranslation:translation inView:self];
}
[super setContentInset:contentInset];
}

Interestingly, UITableView accounts for this by NOT slowing down tracking until you pull PAST the refresh control. However, I don't see a way that this behavior is exposed.

UIRefreshControl not centred with contentInset set

OK, fixed the problem by not setting collectionView.contentInset. Instead I set on the flowLayout

i.e.

flowLayout.sectionInset = UIEdgeInsetsMake(0, 20, 20, 20);

UIRefreshController goes over the UICollectionView

I had this issue as well and figured it out so I thought I would share. what I did was force it to the back of the UICollectionView. I had tried other things like sendSubViewToBack and setting the zIndex of the UICollectionViewCell but it didn't work. However below did work and I tested on iOS 6+:

refreshControl.layer.zPosition = -1;

For iOS 6, add this:

refreshControl.userInteractionEnabled = NO;


Related Topics



Leave a reply



Submit