swift 分页菜单
Hey, today I’m presenting you horizontal pagination in swift 5. The reference I have taken from one of my organisation’s library.
嘿,今天我将向您介绍水平5分页。这是我所在组织的一个图书馆提供的参考资料。
If you are new bee then please refer to following links first
如果您是新蜜蜂,请先参考以下链接
https://developer.apple.com/documentation/uikit/uicollectionview
https://developer.apple.com/documentation/uikit/uicollectionview
https://www.raywenderlich.com/9334-uicollectionview-tutorial-getting-started
https://www.raywenderlich.com/9334-uicollectionview-tutorial-getting-started
水平分页 (Horizontal Pagination)
Basic pagination works as you pulled to a threshold value. Beyond that, it will hit API and gives some array items back, that you will append to the main array. Pagination consist of 2 things refresh all and load more. Refresh all works when you need fresh content from the beginning and load more works when you need more data at the end. In context with horizontal pagination you will drag collection towards the right to refresh all and in case of load more, you will scroll to last content and drag towards left.
基本分页在您达到阈值时起作用。 除此之外,它将击中API并返回一些数组项,您将这些数组项追加到主数组中。 分页由两件事组成,它们全部刷新并加载更多内容 。 当您从一开始就需要新鲜的内容时刷新所有作品,而当您结束时需要更多数据时加载更多作品。 在水平分页的情况下,您将向右拖动集合以刷新所有内容,如果加载更多,则将滚动到最后一个内容并向左拖动。
So moving ahead and let’s create a new project name HorizontalPaginationDemo.
接下来,让我们创建一个新的项目名称HorizontalPaginationDemo。
项目设置 (Project Setup)
Open default Main.Storyboard, there is default view controller in Interface Builder (IB), add UICollectionView with top, left, right and height to 0,0,0 and 200 respectively.
打开默认的Main.Storyboard,在Interface Builder(IB)中有默认的视图控制器,将UICollectionView的top,left,right和height分别添加到0、0、0和200。
There is a default UICollectionViewCell present in the collection view. Extend it and add UILabel in the centre.
集合视图中存在默认的UICollectionViewCell 。 扩展它并在中心添加UILabel 。
Create an IBOutlet