gpt4 book ai didi

ios - AVCapturePhotoOutput : If you specify a non-nil format dictionary in your settings, 您的代表必须响应选择器

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:11:52 25 4
gpt4 key购买 nike

@IBAction func clickPicture(_ sender: UIButton) {

let photoSettings = AVCapturePhotoSettings()
photoSettings.flashMode = .auto
photoSettings.isHighResolutionPhotoEnabled = true
if photoSettings.availablePreviewPhotoPixelFormatTypes.count > 0 {
photoSettings.previewPhotoFormat = [kCVPixelBufferPixelFormatTypeKey as String : photoSettings.availablePreviewPhotoPixelFormatTypes.first!]
}

self.wideAngleOutPut.capturePhoto(with: photoSettings, delegate: self)
}

当我调用上面的函数来捕获在线抛出异常的图像应用程序时:self.wideAngleOutPut.capturePhoto(with: photoSettings, delegate: self)

在日志部分,我可以看到更详细的错误及其类似内容:

由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“* **-[AVCapturePhotoOutput capturePhotoWithSettings:delegate:] 如果您在设置中指定了非零格式字典,则您的代理必须响应选择器****

有人可以帮忙吗?提前致谢。

最佳答案

如果设置了 previewPhotoFormat,则需要在委托(delegate)中实现以下内容。

func capture(_ captureOutput: AVCapturePhotoOutput, didFinishProcessingPhotoSampleBuffer photoSampleBuffer: CMSampleBuffer?, previewPhotoSampleBuffer: CMSampleBuffer?, resolvedSettings: AVCaptureResolvedPhotoSettings, bracketSettings: AVCaptureBracketedStillImageSettings?, error: Error?)

我猜这是因为这是在这种情况下访问预览的唯一方式。

关于ios - AVCapturePhotoOutput : If you specify a non-nil format dictionary in your settings, 您的代表必须响应选择器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44279397/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com