The iPhone 5S is capable of taking pictures while recording video and I am trying to figure out how I would do this programatically. I know I would be utilizing AVFoundation, however, I couldn't find anything in the programming guide regarding this. I have also checked the sample projects (AVFoundation-related) and it doesn't look like there is anything there that does what I am looking for. if you could help point me in the right direction that would be great.
Actually you can do it with any device that can record video:
AVCaptureVideoDataOutput
.AVCaptureSession
.AVCaptureVideoDataOutputSampleBufferDelegate
.captureOutput:didOutputSampleBuffer:fromConnection:
in the delegate and get the image with imageFromSampleBuffer:
.Some similar code can be found here, where images are captured at a given interval, but you only want one image.
In iOS7 there has a new api to capture UIView, we can get image and do something.
eg:
UIView+Screenshot.h
-(UIImage *)convertViewToImage;
UIView+Screenshot.m
-(UIImage *)convertViewToImage
{
UIGraphicsBeginImageContext(self.bounds.size);
[self drawViewHierarchyInRect:self.bounds afterScreenUpdates:YES];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
Apple's Document: drawViewHierarchyInRect:afterScreenUpdates:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With