I am capturing a single frame using
- (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection
Now I want to see this image on a different UIViewController which presents, but it doesn't work. I can display the taken image on the same UIViewController but on the other one it seems to be out of scope.
I tried it this way:
In captureOutput method:
CFRetain(sampleBuffer);
[photoView addFoto:sampleBuffer];
[self performSelectorOnMainThread:@selector(showPhoto:) withObject:nil waitUntilDone:YES];
CFRelease(sampleBuffer);
photoView is the other UIViewController
- (void) addFoto:(CMSam开发者_StackOverflowpleBufferRef) ref
{
UIImage *theImage = imageFromSampleBuffer(ref);
theImage = [[UIImage alloc] initWithCGImage:CGImageCreateCopy(theImage.CGImage)];
capturedImages = [NSMutableArray array];
[capturedImages addObject:theImage];
}
- (void) showPhoto:(UIImage*) bild
{
[session stopRunning];
photoView.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self presentModalViewController:photoView animated:YES];
}
and in the viewDidLoad method of the photoView UIViewController:
- (void)viewDidLoad
{
[super viewDidLoad];
foto.image = [capturedImages objectAtIndex:0];
// Do any additional setup after loading the view from its nib.
}
foto is the UIImageView
Why it doesn't work? I am desperate... Thanks in advance.
- (void) showPhoto:(UIImage*) bild
{
[session stopRunning];
photoView.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self presentModalViewController:photoView animated:YES];
photoView.foto.image = (UIImage*)[capturedImages objectAtIndex:0];
}
精彩评论