开发者

Can we know how many albums there are in the iphone's camera library?

I have a small question. We want the user to the able to choose an image from his device's l开发者_开发问答ibrary. If he has more albums apart from the camera roll, we use UIImagePickerControllerSourceTypePhotoLibrary, so he could browse all the albums. The problem comes when he only has the camera roll. In that case we want him to go directly to the camera roll screen, instead of showing an albums table with the camera roll as only choice. It is an useful step.

The question: Is there way to know that there is only one album (camera roll) in the device, so we use UIImagePickerControllerSourceTypeSavedPhotosAlbum and skip that intermediate case? Is there any other solution?

Thanks a lot.


You can use the ALAssetsLibrary method enumerateGroupsWithTypes:usingBlock:failureBlock: to iterate over all albums in the photo library. It doesn't give you the count directly so you would have to increment your own counter but it should give you the desired result.

Check the documentation for enumerateGroupsWithTypes:usingBlock:failureBlock: for more info on the method.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜