我将 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/