gpt4 book ai didi

ios - 在应用程序中存储大量照片的最佳方式是什么?

转载 作者:行者123 更新时间:2023-11-28 09:28:16 25 4
gpt4 key购买 nike

我说的是 7,500 多张图片。用户需要能够几乎立即访问大约 150 个。

我目前将它们全部保存为 Parse.com 上的 PFFiles,但检索它们非常缓慢且存在错误。

我的想法是将所有这些都存储在设备本地,但这会导致我的应用程序大小约为 1GB。考虑到应用程序的性质,这可能是我愿意做的事情,但有人知道更好的事情吗?

我用 PFFiles 填充 UICollectionViewCells 的代码在这里:

var images = [PFFile]()

func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return images.count
}

func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell: CardsCollectionViewCell = collectionView.dequeueReusableCellWithReuseIdentifier("Cell", forIndexPath: indexPath) as! CardsCollectionViewCell
images[indexPath.row].getDataInBackgroundWithBlock{
(imageData: NSData?, error: NSError?) -> Void in
if error == nil {
let image = UIImage(data: imageData!)
cell.cardsImg.image = image
}
}
return cell
}

最佳答案

正如@rghome 所说,缩略图可能是调整应用大小的一种有趣方式。

如果您真的想将它们放在应用程序中并快速检索它们,我会使用 Realm ( realm.io ),因为它们有一个易于使用且检索数据非常快的数据库。

如果您想将高分辨率图像保留在云中以适应应用程序的大小,那么减小它们在应用程序中的大小(缩略图)可能是一个好方法,但我不喜欢他的方法。

关于ios - 在应用程序中存储大量照片的最佳方式是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31097418/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com