Ios 从图书馆获取最新的十张照片

Ios 从图书馆获取最新的十张照片,ios,uiimage,photo,Ios,Uiimage,Photo,我需要从图书馆获得最新的10张照片并展示它们。如何使用这些照片获取UIImages 我尝试了UIImagePickerController,但我认为这是不可能的。使用Alassets!例如 更新:04/27/14 - (void)loadImageFromIndex:(int)index withAssetLibrary:(ALAssetsLibrary*)library { [library enumerateGroupsWithTypes:ALAssetsGroupSavedPhotos

我需要从图书馆获得最新的10张照片并展示它们。如何使用这些照片获取
UIImage
s


我尝试了UIImagePickerController,但我认为这是不可能的。

使用Alassets!例如

更新:04/27/14

- (void)loadImageFromIndex:(int)index withAssetLibrary:(ALAssetsLibrary*)library {

[library enumerateGroupsWithTypes:ALAssetsGroupSavedPhotos usingBlock:^(ALAssetsGroup *group, BOOL *stop) {
    // Within the group enumeration block, filter to enumerate your photos.
    [group setAssetsFilter:[ALAssetsFilter allPhotos]];

    //if index exceeds bounds, kill the method
    if (index < 0 || index > [group numberOfAssets]-1) {
        return;
    }

    // Chooses the photo at the index
    [group enumerateAssetsAtIndexes:[NSIndexSet indexSetWithIndex:index] options:0 usingBlock:^(ALAsset *alAsset, NSUInteger inde, BOOL *innerStop) {
        // The end of the enumeration is signaled by asset == nil.

        if (alAsset) {
            ALAssetRepresentation *representation = [alAsset defaultRepresentation];
            UIImage *tempImage = [UIImage imageWithCGImage:[representation fullScreenImage]];

            // Do something with the image

            }
        }];
    }

    failureBlock: ^(NSError *error) {
        NSLog(@"None");
    }];
}
-(void)loadImageFromIndex:(int)带有AssetLibrary:(AlassetLibrary*)库的索引{
[库枚举组swithtypes:alassetgroupsavedphotos usingBlock:^(alassetgroup*group,BOOL*stop){
//在组枚举块中,筛选以枚举照片。
[group SetAssetFilter:[AlasSetFilter allPhotos]];
//如果索引超出边界,请终止该方法
if(索引<0 | |索引>[资产组编号]-1){
返回;
}
//选择索引处的照片
[group EnumerateAssetStatIndex:[NSIndexSet IndexSetWithiIndex:index]选项:0使用块:^(ALAsset*ALAsset,NSUTEGER inde,BOOL*innerStop){
//枚举结束由asset==nil表示。
如果(设置){
ALAssetRepresentation*表示=[AlasSetDefaultRepresentation];
UIImage*tempImage=[UIImage imageWithCGImage:[表示全屏图像]];
//对图像做些什么
}
}];
}
故障块:^(N错误*错误){
NSLog(@“无”);
}];
}

AVFoundation.framework。我会告诉你的,谢谢@Roecrew@benLIVE我刚刚更新了代码以更好地适应您的情况。如果您有任何问题,请随时提问!