在我的應用程序中,我想顯示來自giphy的gif。抓取和放置都不是問題,但我不知道以什麼方式顯示所有趨勢圖像的最佳方式。 我應該與此代碼顯示所有的GIF一個的CollectionView:在collectionview中顯示很多gifs
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: GifChooserCell.cellIdentifier, for: indexPath) as! GifChooserCell
let data = try! Data(contentsOf: gif.giphyURL)
let image = FLAnimatedImage(animatedGIFData: data)
cell.image.animatedImage = image
return cell
}
的問題是,這一切都加載到內存和應用是極其緩慢。什麼是最好的方法來做到這一點?異步?延遲加載?
我想你可以看看:http://stackoverflow.com/a/26401392/2894160 –