gpt4 book ai didi

ios - 如何将刷新控件添加到 View Controller 中的水平 collectionview?

转载 作者:搜寻专家 更新时间:2023-10-31 19:35:16 25 4
gpt4 key购买 nike

我目前有:

        refresher = UIRefreshControl()
refresher.attributedTitle = NSAttributedString(string: "Pull to refresh")
refresher.addTarget(self, action: "refresh:", forControlEvents: UIControlEvents.ValueChanged)
self.postsView.addSubview(refresher)

在包含 Collection View 的 View Controller 的 viewdidload() 中。与 collectionview 交互并让自定义单元格正常显示。但是,当我添加这个刷新器时,它没有做任何事情。我不确定为什么,我在这里错过了一步吗?谢谢!

最佳答案

实现 UIScrollview 委托(delegate),请尝试下面的代码

- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
CGPoint offset = scrollView.contentOffset;
CGRect bounds = scrollView.bounds;
CGSize size = scrollView.contentSize;
UIEdgeInsets inset = scrollView.contentInset;
float y = offset.x + bounds.size.width - inset.right;
float h = size.width;


float reload_distance = 75; //distance for which you want to load more
if(y > h + reload_distance) {
// write your code getting the more data
NSLog(@"load more rows");

}
}

关于ios - 如何将刷新控件添加到 View Controller 中的水平 collectionview?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29189491/

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