gpt4 book ai didi

ios - 如何加载更多到 collectionview ?

转载 作者:搜寻专家 更新时间:2023-11-01 07:15:01 24 4
gpt4 key购买 nike

我有一个支持分页的 api。

"pagination":{  
"total":355,
"totalPages":10,
"page":1,
"nextPage":2,
"nextPageUrl":"http://api..................?page=2" }

我的目标是将 nextPageUrl 的图像添加到我的收藏 View 中。那我该怎么做呢?

有什么建议或代码示例吗?我是 swift 的新手。非常感谢:)

最佳答案

您需要在 Collection View 的末尾添加一个按钮,以便每次用户按下此按钮时,您都会再次调用服务器,但调用的是下一页。然后将接收到的数据附加到旧数据并调用 collectionView.reloadData。您也可以不使用按钮,当用户到达 Collection View 的末尾时,它会自动启动。

你可以这样做第二个:

if (CGRectGetMaxY(scrollView.bounds) == scrollView.contentSize.height) {
callToServer()
}

关于ios - 如何加载更多到 collectionview ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42608661/

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