[英]How do get the first(most recent) photo from the Photo Library in ALASSET?
有没有诀窍以编程方式从iOS Photo库中获取最新照片?
我知道我可以按日期搜索,但是我必须每微秒进行一次扫描才能进行某种比较以准确找到它。
有没有人做过这个或任何想法?
我之前采取的一种方法:
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
[library enumerateGroupsWithTypes:ALAssetsGroupSavedPhotos usingBlock:^(ALAssetsGroup *group, BOOL *stop) {
[group setAssetsFilter:[ALAssetsFilter allPhotos]];
[group enumerateAssetsWithOptions:NSEnumerationReverse usingBlock:^(ALAsset *alAsset, NSUInteger index, BOOL *innerStop) {
if (alAsset) {
ALAssetRepresentation *representation = [alAsset defaultRepresentation];
UIImage *latestPhoto = [UIImage imageWithCGImage:[representation fullScreenImage]];
*stop = YES; *innerStop = YES;
}
}];
} failureBlock: ^(NSError *error) {
NSLog(@"Error : %@", [error localisedDescription]);
}];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.