为什么在" reloadCollectionViewDataAtIndexPath(index)"之后,某些单元格会消失?

时间:2015-02-25 04:28:54

标签: ios swift

中的func

func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell

我用

if let imageData_ = imageData{
        cell.setImage(UIImage(data: imageData_))
    }
    else{
        cell.setImage(nil)
        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), { () -> Void in
            var Data = self.getImageFromModel(point, index: indexPath.item)
            if let Data_ = Data{
                self.imageCache.setObject(Data_, forKey: NSString(format: "%d", indexPath.item))
                NSLog("Download Image for %d", indexPath.item)

                self.reloadCollectionViewDataAtIndexPath(indexPath)
            }
            else{
                println("nil Image")
            }

        })
    }

func reloadCollectionViewDataAtIndexPath(indexPath:NSIndexPath){
    var indexArray = NSArray(object: indexPath)
    self.collectionView.reloadItemsAtIndexPaths(indexArray)
}

从网页加载图片,但在加载完所有图片后,一些超出初始场景的单元格消失(在初始场景下方,可以滚动视图)

但是如果我在完全加载所有图像之前滚动视图以使缺失的单元格可见,那么一切都很好......

问题出在哪里..?

0 个答案:

没有答案