所以,我把一些代码放在一起,下载图像并将它们显示在我创建的自定义UICollectionViewCell上,但滚动速度非常慢。下面函数中的代码是否应该移动到NSObject类,可以以某种方式为我下载?我很失落如何加快速度......
提前谢谢! :)
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCellWithReuseIdentifier("Cell", forIndexPath: indexPath) as HomeCollectionViewCell
cell.backgroundColor = UIColor.lightGrayColor()
var post:PFObject = self.posts.objectAtIndex(indexPath.row) as PFObject
var imageFile:PFFile = post.objectForKey("file") as PFFile
var imageFileURL:NSURL = NSURL(string: imageFile.url)!
var imageData:NSData = NSData(contentsOfURL: imageFileURL)!
cell.imageView.image = UIImage(data: imageData)
return cell
}