使用AVCam示例,我不知道如何访问AVCamViewController.m文件中的图像。我想预览捕获的图像,但我不知道如何在[[self captureManager] captureStillImage];行后面的- (IBAction)captureStillImage:(id)sender方法中访问此图像
我想以编程方式添加一个预览,如下所示:
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320/5, 480/5)];
[imageView setImage:[captureManager image]];
[self.view addSubview:imageView];
[imageView release];我试图在这方面寻求帮助,但无法做到。在座的各位有什么建议吗?
发布于 2012-09-10 17:18:11
AVcam将捕获的图像存储在照片库中您需要从照片库访问上次保存的图像为此您可以使用此method.You还需要添加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);
}];
}https://stackoverflow.com/questions/11977859
复制相似问题