繁体   English   中英

iPhone-UIImagePickerController进行屏幕截图吗?

[英]iPhone - UIImagePickerController take screen shots?

我正在尝试使用以下代码从uiimagePickerController拍摄屏幕截图

UIGraphicsBeginImageContext(imagePicker.view.bounds.size);
[self.imagePicker.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

它显示了所有内容,除了从相机捕获的内容外,我看到了“取消”按钮,拍摄了照片。 它捕获了黑屏,而不是在相机上显示什么,可以采取任何措施吗? 还是一种更好的方法来每1秒自动从相机中捕获图像?

- (void)captureOutput:(AVCaptureOutput *)captureOutput 
didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer 
       fromConnection:(AVCaptureConnection *)connection
{ 
    UIImage *image = [self imageFromSampleBuffer:sampleBuffer];
    UIImageView *img = [[UIImageView alloc] initWithImage:image];
    [img setFrame:CGRectMake(0, 0, 320, 480)];
    [self.view addSubview:img];
    [img release];
}

您要使用新的(在OS 4中)AVFoundation API。

尝试此页面获取一些信息:

http://developer.apple.com/iphone/library/qa/qa2010/qa1702.html

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM