嗨我有一个阵列与100张图片url从flickr采取。当我使用UICollectionView我显示100个细胞中,只有8个细胞是在屏幕上,当我向下滚动才能看到未来8他们像以前一样,当我执行Swift - UICollectionView重复(重复)单元格
func collectionView(collectionView: UICollectionView!, cellForItemAtIndexPath indexPath: NSIndexPath!) -> UICollectionViewCell!
和println(“东西”)它在控制台只写8次的东西,但阵列的含量为100
我用这个:
func collectionView(collectionView: UICollectionView?, numberOfItemsInSection section: Int) -> Int {
return self.photosUrls.count
}
它使100个细胞,但细胞总是重复...任何人谁知道如何击败斯威夫特在XCode GM种子的新版本中?
func collectionView(collectionView: UICollectionView!, cellForItemAtIndexPath indexPath: NSIndexPath!) -> UICollectionViewCell! {
let cell: ImageCell = collectionView.dequeueReusableCellWithReuseIdentifier("Cell", forIndexPath: indexPath) as ImageCell
let imgUrl = photosUrls[indexPath!.row]
let api_url = NSURL.URLWithString(imgUrl)
let URLReq = NSURLRequest(URL: api_url)
let NSOpQ:NSOperationQueue = NSOperationQueue()
NSURLConnection.sendAsynchronousRequest(URLReq, queue: NSOpQ, completionHandler:{ (response: NSURLResponse!, data: NSData!, error: NSError!) -> Void in
if(error == nil){
cell.theWPImage!.image = UIImage(data: data)
}
})
return cell
}
我添加了代码。看到它,谢谢:) – 2014-09-11 08:01:22