Ios 在UICollectionView中拉入UIRefreshControl后,UIRefreshControl不会粘滞

Ios 在UICollectionView中拉入UIRefreshControl后,UIRefreshControl不会粘滞,ios,uirefreshcontrol,Ios,Uirefreshcontrol,我正在将UIRefreshControl与UICollectionView一起使用。刷新可以工作,但拉取后视图不会保持在顶部(与uitableview一样)。有没有一种方法可以让它保持不变,或者只针对UITableViewController实现 self.refreshControl = [[UIRefreshControl alloc] init]; self.refreshControl.attributedTitle = [[NSAttributedString alloc] initW

我正在将UIRefreshControl与UICollectionView一起使用。刷新可以工作,但拉取后视图不会保持在顶部(与uitableview一样)。有没有一种方法可以让它保持不变,或者只针对UITableViewController实现

self.refreshControl = [[UIRefreshControl alloc] init];
self.refreshControl.attributedTitle = [[NSAttributedString alloc] initWithString:@"Pull to Refresh"];
[self.refreshControl addTarget:self action:@selector(refresh:) forControlEvents:UIControlEventValueChanged];
[self.collectionView addSubview:self.refreshControl];
[self.collectionView setAlwaysBounceVertical:YES];

对我来说,只有在调用
.endRefreshing()
之前尝试更新单元格时才会发生这种情况


因此,要修复此问题,需要首先调用
.endRefreshing()
,然后更新单元格(
重新加载数据
等等)。

嗨!你找到解决这个问题的方法了吗?嗨,不完全是-我没有找到使用UIRefreshControl的方法,所以我使用UIView和scroll事件创建了一个自定义刷新视图。