Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/42.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone AVCamDemo:completionHandler代码未命中_Iphone_Avfoundation_Image Capture - Fatal编程技术网

Iphone AVCamDemo:completionHandler代码未命中

Iphone AVCamDemo:completionHandler代码未命中,iphone,avfoundation,image-capture,Iphone,Avfoundation,Image Capture,我正在精简AVCamDemo项目,这样我就可以尝试只捕获静态图像 下面是captureStillImage()方法的新代码: - (void) captureStillImage { AVCaptureConnection *stillImageConnection = [AVCamUtilities connectionWithMediaType:AVMediaTypeVideo fromConnections:[[self stillImageOutput] connections]

我正在精简
AVCamDemo
项目,这样我就可以尝试只捕获静态图像

下面是
captureStillImage()
方法的新代码:

- (void) captureStillImage
{
    AVCaptureConnection *stillImageConnection = [AVCamUtilities connectionWithMediaType:AVMediaTypeVideo fromConnections:[[self stillImageOutput] connections]];
    if ([stillImageConnection isVideoOrientationSupported]) {
        [stillImageConnection setVideoOrientation:orientation];
    }
    [[self stillImageOutput] captureStillImageAsynchronouslyFromConnection:stillImageConnection
                completionHandler:^(CMSampleBufferRef imageDataSampleBuffer, NSError *error) {
NSLog(@"In the completionHandler block");
           if (imageDataSampleBuffer != NULL) {
               NSData *imageData = [AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:imageDataSampleBuffer];
               UIImage *image = [[UIImage alloc] initWithData:imageData];
                     [self writeImageFile:image];
                     [image release];
            }
          if ([[self delegate] respondsToSelector:@selector(captureManagerStillImageCaptured:)]) {
               [[self delegate] captureManagerStillImageCaptured:self];
                }
     }];
NSLog(@"exiting....");
}
在我的测试中,我发现有时候,块中的NSLog语句没有执行…因此静态图像文件没有保存

我遇到时间问题了吗?如果是,我如何称呼他们

谢谢,并致以问候。 山姆