如何将ALAsset添加到Photo Stream?

时间:2012-11-12 17:16:43

标签: ios icloud alassetslibrary alasset

我尝试将ALAsset添加到Photo Stream,但看起来这是不可能的。 有什么建议吗?

我尝试了以下内容:

typedef void(^SaveImageCompletion)(NSError* error);

-(void)addAssetURL:(NSURL*)assetURL toPhotoStreamWithCompletionBlock:(SaveImageCompletion)completionBlock
{
    [self enumerateGroupsWithTypes:ALAssetsGroupPhotoStream usingBlock:^(ALAssetsGroup *group, BOOL *stop) {

        if (group) {
            *stop = YES;
            [self assetForURL: assetURL resultBlock:^(ALAsset *asset) {
                if ([group addAsset: asset]) {
                    NSLog(@"Added to photo stream!");
                } else {
                    NSLog(@"ERROR! Adding to photo stream failed!");
                }
                                 completionBlock(nil);

            } failureBlock: completionBlock];
            return;
        }

    } failureBlock: completionBlock];    
}

但是,addAsset:总是失败。它适用于常规专辑..

非常感谢提前!

1 个答案:

答案 0 :(得分:0)

从iOS 8开始Apple已经创建了Photos框架来完成这些工作。

广泛Photos framework sample project