当我使用媒体库时,我收到内存警告。它将我的相机胶卷中的所有图像/视频提取到提取结果中,您可以使用 UIPageControl 滑动内容。
当我使用“仪器”时,它显示:
这是一些代码
func showImage(obj: AnyObject!) {
var image = UIImage()
manager.requestImageForAsset(obj as! PHAsset, targetSize: PHImageManagerMaximumSize, contentMode: .AspectFit, options: photoOptions, resultHandler:
{(result, info)->Void in
image = result!
self.imageView.image = image
self.imageView.frame = self.contentView.bounds
self.contentView.addSubview(self.imageView)
})
}
在这里,我将媒体获取到我的 PHFetch 结果:
fetchOptions.sortDescriptors = [NSSortDescriptor(key: "creationDate", ascending: true)]
PHAsset.fetchAssetsWithMediaType(.Image, options: fetchOptions)
PHAsset.fetchAssetsWithMediaType(.Video, options: fetchOptions)
let media = PHAsset.fetchAssetsWithOptions(fetchOptions)
我完全不知道这意味着什么,因为我是 XCode 和 Swift 的新手。那么可能是什么原因呢?
提前致谢
最佳答案
您有近 1GB 的 CGImage 分配。您应该尝试重用单元格或 ImageView ,释放未使用的图像。仅当您要在屏幕上显示图像时才获取图像,不要获取整个相机胶卷。如果您不使用全屏图像,则应该显示缩略图。
关于ios - 当我在 Swift 中使用 PHAsset 时,我总是收到内存警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38746570/