我已经实现了一个简单的方法来查找设备内图像的路径。实际上我正在使用 iPhone 模拟器。这是我正在使用的代码:
[library enumerateGroupsWithTypes:ALAssetsGroupAll usingBlock:^(ALAssetsGroup *group, BOOL *stop) {
if (group) {
[group setAssetsFilter:[ALAssetsFilter allPhotos]];
[group enumerateAssetsUsingBlock:^(ALAsset *asset, NSUInteger index, BOOL *stop){
if (asset){
NSString *description = [asset description];
NSRange first = [description rangeOfString:@"URLs:"];
NSRange second = [description rangeOfString:@"?id="];
NSString *path = [description substringWithRange: NSMakeRange(first.location + first.length, second.location - (first.location + first.length))];
[idList addObject:path];
}
}];
}
} failureBlock:^(NSError *error) {
NSLog(@"error enumerating AssetLibrary groups %@\n", error);
}
];
});
此时,如果我记录我收到的图像的路径:“assets-library://asset/asset.JPG”,据我所知,这并不是图像的确切位置的整个路径. 你还好吗?那么,我怎样才能获得资产的整个路径呢?
谢谢