iPhone ALAssetsLibrary获取所有图像并进行编辑 [英] iPhone ALAssetsLibrary get all images and edit

查看:160
本文介绍了iPhone ALAssetsLibrary获取所有图像并进行编辑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请帮我解答一下我的问题:

please help me with my question:

我可以使用ALAssetsLibrary为iPhone库中的所有图像/视频提供网址和元数据吗?
我可以编辑/删除这些图像/视频吗?

Can I give URLs and metadata for all the images/videos in iPhone library with ALAssetsLibrary? Can I edit/delete these images/videos?

推荐答案

查看ALAssetsLibrary的文档此处。要访问所有照片和视频,您需要枚举照片库中的所有组(相册),然后枚举每组中的所有照片和图像。您无法使用API​​删除资产。 iOS 5增加了额外的功能 - 它仍然在NDA下,但不能在这里讨论 - 看一下beta5文档和iOS5的Apple Developer论坛。

Take a look at the documentation for ALAssetsLibrary here. To access all photos and videos you need to enumerate all groups (albums) in the photo library and then enumerate all photos and images in each group. You cannot delete assets using the API. iOS 5 adds extra functionality - it's still under NDA though and cannot be discussed here - have a look at the beta documentation and Apple Developer forums for iOS5.

你的代码需要做这样的事情:

Your code will need to do something like this:

ALAssetsLibrary *al = [[ALAssetsLibrary alloc] init];


[al enumerateGroupsWithTypes:ALAssetsGroupAll

    usingBlock:^(ALAssetsGroup *group, BOOL *stop)
    {
        [group enumerateAssetsUsingBlock:^(ALAsset *asset, NSUInteger index, BOOL *stop)
        {
            if (asset)
            {                
                 .. do something with the asset
            }
        }
        ];
    }

    failureBlock:^(NSError *error)
    {
        // User did not allow access to library
        .. handle error 
    }
 ];

这篇关于iPhone ALAssetsLibrary获取所有图像并进行编辑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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