我正在使用翠鸟框架从网络下载图片并缓存它们。我有一个包含很多Facebook id的数组,代码需要下载每个id的图片。现在,代码下载newArray的图片,但它应该为存储在数组中的每个id下载图片。
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的代码并在集合视图中显示它吗?任何帮助都是非常感谢的,真的!谢谢!
发布于 2015-09-19 04:01:19
你可以在你的方法中使用indexPath.row。
示例:
let URL = NSURL(string: "http://graph.facebook.com/" + newArray[indexPath.row] + "/picture?type=large")!https://stackoverflow.com/questions/32660047
复制相似问题