AVcam 将捕获的图像存储在照片库中,您需要访问照片库中最后保存的图像,您可以使用此方法。您还需要添加 AssetsLiberary.framework 以使用此 als 添加此#include 在 .h 文件中
#include <AssetsLibrary/AssetsLibrary.h>
@interface PhotoViewController : UIViewController<UIImagePickerControllerDelegate,UIPopoverControllerDelegate>{
ALAssetsLibrary *assetsLibrary;
}
- (void)viewDidLoad
{
assetsLibrary = [[ALAssetsLibrary alloc] init];
[self updateLastPhotoThumbnail];
}
- (void)updateLastPhotoThumbnail
{
[assetsLibrary enumerateGroupsWithTypes:ALAssetsGroupSavedPhotos usingBlock:^(ALAssetsGroup *group, BOOL *stop) {
NSInteger numberOfAssets = [group numberOfAssets];
if (numberOfAssets > 0) {
NSInteger lastIndex = numberOfAssets-1;
[group enumerateAssetsAtIndexes:[NSIndexSet indexSetWithIndex:lastIndex] options:0 usingBlock:^(ALAsset *result, NSUInteger index, BOOL *stop) {
UIImage *thumbnail = [UIImage imageWithCGImage:[result thumbnail]];
if (thumbnail && thumbnail.size.width > 0) {
YouImageView.image = thumbnail;
*stop = YES;
}
}];
}
} failureBlock:^(NSError *error) {
NSLog(@"error: %@", error);
}];
}