【问题标题】:How I can implement pegination on collection view when collection view scroll? In ios集合视图滚动时如何在集合视图上实现分页?在 iOS 中
【发布时间】:2019-02-12 01:36:07
【问题描述】:

我想在 collectionview 中实现 pegination,并在最后一项下方刷新一个视图,我们如何在 swift 4 中实现这一点?

【问题讨论】:

  • 这可能对您有所帮助。 link
  • 到目前为止你做了什么尝试,遇到了什么问题?
  • 感谢您的建议,我已经更改了标签。

标签: ios


【解决方案1】:

我已将 2 个公共变量声明为:

var page_number = 1
var total_count = 0

并编辑 willDisplay 委托方法为:

func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath) 
{  
    if(indexPath.item == (arrayProperties.count - 1) && arrayProperties.count < total_count )
    {
        page_number = page_number+1

        // Call api with updated page_number
          callApi(pageNumber: page_number)
    }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-06-02
    • 2017-11-21
    • 1970-01-01
    相关资源
    最近更新 更多