UICollectionView 中的 UIRefreshControl(从左到右刷新)概念水平 [英] UIRefreshControl( pull left to right refresh ) concept in UICollectionView horizontally

查看:22
本文介绍了UICollectionView 中的 UIRefreshControl(从左到右刷新)概念水平的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个自定义的水平集合视图,它有 1 行,我想添加下拉刷新功能,默认情况下,它显示在我的单元格行上方.我希望用户能够从左到右拉取集合视图以激活 UIRefreshControl.有什么想法吗?

I have a custom horizontal collection view that has 1 row and I want to add pull to refresh functionality which, by default, appears above my row of cells. I would like the user to be able to pull the collection view from left to right to activate the UIRefreshControl. Any ideas?

推荐答案

为此你需要实现 UIScrollViewDelegate 方法

For this you need to implement the UIScrollViewDelegate method

- (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");

    }

}

这篇关于UICollectionView 中的 UIRefreshControl(从左到右刷新)概念水平的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆