ios 8,如何使用ALAssetLibrary获取所有照片以替换丢失的相机胶卷相册 [英] ios 8, how to get all photos using ALAssetLibrary to replace the missing camera roll album

查看:199
本文介绍了ios 8,如何使用ALAssetLibrary获取所有照片以替换丢失的相机胶卷相册的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序有一个自定义图像选择器,它使用ALAssetLibrary创建一个Album选择器和图像选择器。我们已经实施了一个自定义选择器,以便我们的客户选择多个图像。此图像选择器在iOS 7下运行良好,并显示包含所有用户照片的相机胶卷相册。但是,在iOS 8下运行相同的应用程序时,似乎Apple已从相册视图中删除了相机胶卷相册,并且仅显示最近的照片。从我所看到的,访问iOS 8中所有照片的唯一方法是通过Collection视图(在Photos应用程序或新的内置选择器中)。不幸的是,我现在不能使用Photokit,因为我仍然需要支持我的iOS 6& 7位用户有没有人知道在iOS 8(在Xcode 5中编译)运行iOS 7应用程序时使用ALAssetLibrary获取所有资产并创建自定义相机胶卷相册的方法?

I have an app that has a custom Image Picker that uses the ALAssetLibrary to create an Album picker and image picker. We've implemented a custom picker in order for our customers to select multiple images. This image picker works great under iOS 7 and shows the "Camera Roll" album with ALL the user's photos. However, when running the same app under iOS 8, it seems that Apple has removed the "Camera Roll" album from the Albums view and only shows "Recent Photos". From what I can see, the only way to access all photos in iOS 8 is through the Collection view (in the Photos app or the new built-in picker). Unfortunately, I can't use Photokit at this time because I still need to support my iOS 6 & 7 users. Does anyone know of a way to obtain all the assets and create a custom camera roll album using the ALAssetLibrary when running an iOS 7 app under iOS 8 (compiled in Xcode 5)?

更新

好吧,正如我在上面的原帖中所述,我最初无法使用新的照片框架(PhotoKit)。但是,我们最近将构建版本移至Xcode 6,现在我可以使用照片框架创建一组所有照片(请参阅WWDC ExampleappusingPhotosframework示例代码以了解如何执行此操作)。

Well, as I stated in my original post above, I was not initially able to use the new Photos Framework (PhotoKit). However, we recently moved our builds to Xcode 6 and I can now use the photos framework to create a group of all photos (look at the WWDC ExampleappusingPhotosframework sample code for how to do this).

然而,就像每个人都说PhotoKit一样强大,它缺少一些关键的过滤功能。实际上,没有简单的方法可以使用带有PHFetchResult的谓词来过滤原始PhotoStream中的照片。你只能使用公共场所。幸运的是,我想出了如何使用PHAsset描述过滤它们。如果照片位于用户的照片流中,则说明中列出的assetSource键等于2。因此,我在结果上使用了快速枚举,并使用asset.description属性上的简单stringInRange过滤器将所有资源移动到不在PhotoStream中的数组(查找assetSource = 2)。它可能不是最好的解决方案,但它现在可以工作,因此用户不会从本地库和他们的照片流中看到他们的照片重复。至少我可以呈现所有客户的照片,并允许我的多媒体选择器与使用ALAssetLibrary的原始类一样接近。

However, as powerful as everyone is saying PhotoKit is, it's missing some crucial filtering capabilities. In fact there is no easy way to filter out photos in the original "PhotoStream" using a predicate with PHFetchResult. You can only use the public properites. Fortunately, I figured out how to filter them using the PHAsset description. The assetSource key listed in the description is equal to 2 if the photo is in the user's photostream. So, I used fast enumeration on the results and moved all the assets to an array that were not in the PhotoStream using a simple stringInRange filter on the asset.description property (looking for "assetSource=2"). It may not be the best solution, but it works for now so a user does not see duplicates of their photos from both the local library and their photostream. At least I can present all the customer's photos and allow my multi media picker to function as close as the original class that used the ALAssetLibrary.

无论如何,如果有人有使用谓词的更好的解决方案,请lmk。

By all mean, if someone has a better solution using a predicate, please lmk.

推荐答案

好吧,好像它只是一个bug,而且是iOS 8.0。 2修复它(至少对我来说,因为我现在可以看到图像选择器中的所有照片)。

Alright, so seems like it was just a bug, and iOS 8.0.2 fixed it (at least for me, as I can now see all the photos in the image picker).


此版本包含改进和错误修复,包括:

This release contains improvements and bug fixes, including:

[...]
修复了导致某些应用无法访问照片库中的照片的问题。 [...]

[...] Fixes an issue that prevented some apps from accessing photos from the Photo Library. [...]

这篇关于ios 8,如何使用ALAssetLibrary获取所有照片以替换丢失的相机胶卷相册的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆