ios - 拉入 UICollectionView 后 UIRefreshControl 不粘

标签 ios uirefreshcontrol

我将 UIRefreshControl 与 UICollectionView 一起使用。刷新有效,但 View 在拉动后不会停留在顶部(与 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(),然后更新单元格(reloadData 等)。

关于ios - 拉入 UICollectionView 后 UIRefreshControl 不粘,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26618594/

相关文章:

ios - 使用大标题时,不会触发 UIScrollView 中的 UIRefreshControl

ios - 调整 UITableView 高度(嵌入在 UIScrollView 中)

javascript - sessionStorage 不适用于 iphone 6 上的 safari - 非私有(private)模式

ios - 收取未通过 iOS App Store 完成的月度订阅

ios - GMSCoordinateBounds 角值 - Google Maps SDK

ios - 顶部和底部 UIcollectionView 上的 UIrefresh 控件

ios - swift:在 Collection View 中的标签中显示进度

ios - 在 UITableView 下面添加一个 UIRefreshControl

ios - 当项目很少时,collectionView 不会滚动

ios - 拉动刷新默认刷新级别更改