当前位置 : 主页 > 手机开发 > 其它 >

示例AVCAM – Swift Xcode v9

来源:互联网 收集:自由互联 发布时间:2021-06-11
@objc func didTapCameraView() { self.cameraView.isUserInteractionEnabled = false self.spinner.isHidden = false self.spinner.startAnimating() let settings = AVCapturePhotoSettings() let previewPixelType = settings.availablePreviewPhotoPixelF
@objc func didTapCameraView() {
    self.cameraView.isUserInteractionEnabled = false
    self.spinner.isHidden = false
    self.spinner.startAnimating()

    let settings = AVCapturePhotoSettings()
    let previewPixelType = settings.availablePreviewPhotoPixelFormatTypes.first!
    let previewFormat = [kCVPixelBufferPixelFormatTypeKey as String: previewPixelType, kCVPixelBufferWidthKey as String: 160, kCVPixelBufferHeightKey as String: 160]

    settings.previewPhotoFormat = previewFormat

    if flashControlState == .off {
        settings.flashMode = .off
    } else {
        settings.flashMode = .on
    }
    cameraOutput.capturePhoto(with: settings, delegate: self)
}

当我使用Xcode 9 swift 4运行应用程序时,我收到此错误

Undefined symbols for architecture x86_64:
“__T0So22AVCapturePhotoSettingsC12AVFoundation01_abC16SwiftNativeTypesACWP”,
referenced from:
__T014vision_app_dev8CameraVCC06didTapD4ViewyyF in CameraVC.o “__T012AVFoundation39_AVCapturePhotoSettingsSwiftNativeTypesPAAE016availablePreviewc11PixelFormatG0Says6UInt32VGfg”,
referenced from:
__T014vision_app_dev8CameraVCC06didTapD4ViewyyF in CameraVC.o ld: symbol(s) not found for architecture x86_64 clang: error: linker
command failed with exit code 1 (use -v to see invocation)

尝试改变
让previewPixelType = settings.availablePreviewPhotoPixelFormatTypes.first!

让previewPixelType = settings .__ availablePreviewPhotoPixelFormatTypes.first!

*** Apple意外地将一些AVFoundation API外部协议私有化,因此在访问它们的方法之前有2个不受欢迎的_.

资料来源:https://forums.developer.apple.com/thread/86810#259270

资料来源:Try Sample AVCAM from apple found error

网友评论