iPhone 照片库可用空间
我想将照片保存在照片库中,但在此之前我需要知道是否有足够的可用空间来执行此操作。 我如何知道照片库中是否有足够的可用空间来保存我的照片?
我的问题是我需要从服务器下载图像,但执行此操作的决定包括照片库应用程序中是否有足够的空间。
谢谢。
I want to save photo in Photo Library, but before this i need to know if there is enough free space to do it.
How i can to know if there is enough free space to save my picture in Photo Library ?
My problem is that i need to download image from the server, but decision to do it includes if there is enough space in Photo Library application.
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我做了一些检查,苹果似乎没有提供使用 ALAssetLibrary 时检查磁盘空间的方法。但是,如果操作由于磁盘空间问题而失败,它们会提供错误代码。
我建议您尝试保存图像并确保检查完成块中返回的错误并相应地通知用户。
ALAssetsLibraryWriteImageCompletionBlock 有一个 NSError 参数,可以是以下
错误代码 之一
AssetsLibrary 相关错误代码
如果您之前想要进行一些额外的检查,可以使用注释中提到的方法来查找设备上的可用磁盘空间,但不能保证 AssetLibrary 不会使用不同的逻辑来计算磁盘空间需求。
I did some checking and it doesn't seem that Apple provide a way to check disk space when using ALAssetLibrary. They do however provide an error code, it the operation failed due to disk space issue.
I suggest you just try save the image and make sure you check the error returned in the completion block and notify the user accordingly.
ALAssetsLibraryWriteImageCompletionBlock has a NSError argument which can be one of the following
Error Codes
AssetsLibrary-related error codes
If you want some additional checks before, you can use the method mentioned in the comments to find the available disk space on the device, but there's no guarantee AssetLibrary doesn't use different logic to calculate disk space requirements.