如何避免 AlAssetLibrary 中的定位服务?我可以在不使用定位服务的情况下使用 AlAssetLibrary 检索文件吗?
我创建了一个应用程序来使用 ALAssetLibrary 从 iPhone 照片文件夹中获取图像。 我可以在不使用定位服务的情况下使用 AlAssetLibrary 检索文件吗? 如何避免 AlAssetLibrary 中的定位服务?
i created a application to get images from iPhone photo Folder using ALAssetLibrary.
Can i retrieve files using AlAssetLibrary without using Location Service?
How can i avoid Location service in AlAssetLibrary?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
目前,如果不使用位置服务,则无法访问 ALAssetLibrary。你必须使用更有限的 UIImagePickerController 来解决这个问题。
Currently there is no way to access ALAssetLibrary without using location services. You have to use the, much more limited, UIImagePickerController to get around that problem.
如果您只需要库中的一张图像,则上述答案是不正确的。例如,如果您让用户选择要上传的照片。在这种情况下,您可以使用 ALAssetLibrary 获取单个图像,而无需位置权限。
为此,请使用 UIImagePickerController 选择图片;你只需要 UIImagePickerControllerReferenceURL ,它是 UIImagePickerController 提供的。
这样做的好处是可以让您访问未修改的 NSData 对象,然后您可以上传该对象。
这很有用,因为稍后使用
UIImagePNGRepresentation()
或UIImageJPEGRepresentation()
重新编码图像会使文件大小加倍!呈现选择器:
获取图像和/或数据:
The above answer is incorrect if you only need one image from the library. For example, if you are having the user choose a photo to upload. In this case you can get that single image with ALAssetLibrary, without needing Location permissions.
To do this, use a UIImagePickerController to select the picture; you just need the
UIImagePickerControllerReferenceURL
, which the UIImagePickerController provides.This has the benefit of giving you access to an unmodified
NSData
object, which you can then upload.This is helpful because re-encoding the image later using
UIImagePNGRepresentation()
orUIImageJPEGRepresentation()
can double the size of your file!To present the picker:
To get the image and/or data: