问题
I want to provide my users a photo picker which displays all their images similarly to the Photos app. Currently I can use two frameworks, the old Assets Library and the new Photos Library frameworks. Is there any recommendation how should I choose between these two?
The documentation states:
In iOS 8.0 and later, use the Photos framework instead of the Assets Library framework. The Photos framework provides more features and better performance for working with a user’s photo library.
But as my tests show, there are some cases when the user has not yet been enabled iCloud Photo Library, thus I can retrieve none of their photos via the new framework. How can I detect if iCloud Photo Library is enabled? And if enabled, the old framework more or less still works, but it seems that does not show every photo. Which photos does it show? Shall I continue using it? I can't find any documentation about this.
回答1:
I've made an app with Assets Library framework and I'm testing another one with Photos framework.
On my iPhone I haven't enabled iCloud Photo Library, but with both frameworks I can retrieve all the photos.
On the other hand, on my iPad I've enabled iCloud Photo Library with "Optimize [device] Storage" option. In this case (https://support.apple.com/en-us/HT204264):
All of your original, full-resolution photos and videos are stored in iCloud while device-size versions are kept on your device. You can download the original photos and videos over Wi-Fi or cellular when you need them.
On iPad, with the Photos framework I can retrieve all photos, while with the old app using Assets Library I find only the downloaded ones (i.e. the images I've requested with the app using Photos framework).
I think that if you select the other option: "Download and Keep Originals" both frameworks can retrieve all photos (but I haven't tried yet).
I hope this can help.
来源:https://stackoverflow.com/questions/29753485/when-can-i-use-photos-framework-and-icloud-photo-library