捕获后调用 voidStillImageAsynclyFromConnection



我正在尝试运行void saveImageToLibrary

[self.avSnapper captureStillImageAsynchronouslyFromConnection:captureConnection
                                                completionHandler:handler]; 

完成了。我该怎么做?

我想这就是你想要的

[self.avSnapper captureStillImageAsynchronouslyFromConnection:videoConnection completionHandler: ^(CMSampleBufferRef imageSampleBuffer, NSError *error){
     CFDictionaryRef exifAttachments = CMGetAttachment( imageSampleBuffer, kCGImagePropertyExifDictionary, NULL);
     if (exifAttachments){
        // Do something with the attachments if you want to. 
        NSLog(@"attachements: %@", exifAttachments);
    }
    else
        NSLog(@"no attachments");
    NSData *imageData = [AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:imageSampleBuffer];
    UIImage *image = [[UIImage alloc] initWithData:imageData];
    self.vImage.image = image;
}];

如果需要在函数完成时运行一些代码,则有"completionHandler"参数。

根据文档:"捕获图像后要调用的块。

编辑:您可以在此处阅读有关块编程的信息。由于块表示法可能有点令人困惑,因此有一个简单的技巧可能会对您有所帮助。使用自动完成在 XCode 中创建函数签名时,需要传递的变量具有蓝色占位符。现在,当您在块占位符上点击"输入"时,XCode 会为您生成具有匹配语法的空块。

相关内容

  • 没有找到相关文章

最新更新