如何在Swift中的UICollectionView中添加分页? [英] How to add pagination in UICollectionView in swift?
问题描述
我有一个显示项目的UICollection视图.现在,我想在UICollectionView上添加分页.我不想使用任何第三方使用此功能.请让我知道我如何实现这一目标!
I have a UICollection view which shows items. Now I want to add pagination on UICollectionView. I do not want to use any third party for this functionality. Please let me know how I can achieve this!
我有四个示例 http://slicode.com/bottom-refresh-control- uicollectionview/
但是在此过程中,我必须向上拖动scrollview几秒钟以使其正常运行.
But in this I have to drag scrollview upwards for few second to make it work.
推荐答案
如果要添加底部刷新控件,则必须使用以下帮助程序类.
If you want to add bottom refresh control you have to use below helper class.
https://github.com/vlasov/CCBottomRefreshControl/tree/master/Classes
下载Objective-C中的这2个文件.您必须将此文件导入桥接头文件
Download this 2 files which is in Objective-C. You have to import this file in Bridging header
#import "UIScrollView+BottomRefreshControl.h"
添加这样的刷新控件.
let refreshControl = UIRefreshControl.init(frame: CGRect(x: 0, y: 0, width: 50, height: 50))
refreshControl.triggerVerticalOffset = 50.0
refreshControl.addTarget(self, action: #selector(paginateMore), for: .valueChanged)
collectionView.bottomRefreshControl = refreshControl
此帮助器类为您提供了新的bottomRefreshControl
属性,可帮助您在底部添加刷新控件.
This helper class provide you new bottomRefreshControl
property, which helps you to add refresh control in bottom.
这篇关于如何在Swift中的UICollectionView中添加分页?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!