gpt4 book ai didi

ios - 拉入 UICollectionView 后 UIRefreshControl 不粘

转载 作者:可可西里 更新时间:2023-11-01 06:17:17 27 4
gpt4 key购买 nike

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

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com