首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >重复图像下载过程

重复图像下载过程
EN

Stack Overflow用户
提问于 2015-09-19 03:55:16
回答 1查看 186关注 0票数 1

我正在使用翠鸟框架从网络下载图片并缓存它们。我有一个包含很多Facebook id的数组,代码需要下载每个id的图片。现在,代码下载newArray的图片,但它应该为存储在数组中的每个id下载图片。

代码语言:javascript
复制
override func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
    return newArray.count

}

override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
    let cell = collectionView.dequeueReusableCellWithReuseIdentifier("collectionViewCell", forIndexPath: indexPath) as! CollectionViewCell
    cell.imageView.kf_showIndicatorWhenLoading = true

    let URL = NSURL(string: "http://graph.facebook.com/" + newArray[0] + "/picture?type=large")!
    cell.imageView.kf_setImageWithResource(Resource(downloadURL: URL), placeholderImage: nil, optionsInfo: nil, progressBlock: { (receivedSize, totalSize) -> () in

    }) { (image, error, cacheType, imageURL) -> () in

    }
    return cell
}

}

你知道我如何让它循环遍历每个id的代码并在集合视图中显示它吗?任何帮助都是非常感谢的,真的!谢谢!

EN

回答 1

Stack Overflow用户

发布于 2015-09-19 04:01:19

你可以在你的方法中使用indexPath.row

示例:

代码语言:javascript
复制
let URL = NSURL(string: "http://graph.facebook.com/" + newArray[indexPath.row] + "/picture?type=large")!
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32660047

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档