【问题标题】:iOS AVFoundation's AVCapturePhotoOutputiOS AVFoundation 的 AVCapturePhotoOutput
【发布时间】:2017-03-07 18:56:55
【问题描述】:

我正在尝试摆脱 AVCaptureStillImageOutput 并采用 iOS 10 中引入的 AVCapturePhotoOutput

但是,我的部署操作系统是 iOS 9.0。 AVCapturePhotoOutput 还能在 iOS 9 上运行吗?

【问题讨论】:

  • 不,要在 iOS 9 上运行,您需要在代码中保留旧的 AVCaptureStillImageOutput。在 iOS 9 上使用 AVCapturePhotoOutput 很可能会导致崩溃。

标签: ios swift xcode avfoundation avcaptureoutput


【解决方案1】:

这是不可能的,因为AVCapturePhotoOutput 是在 iOS 10 SDK 中引入的,因此该类在比这更早的 SDK 中不可用。如果您需要保持对 iOS 9 的向后兼容性,您将不得不做一些额外的工作,直到您可以放弃支持。在 Swift 中,您可以使用内置的 #available 语法:

if #available(iOS 10, *) {
    // use AVCapturePhotoOutput
}
else {
    // use AVCaptureStillImageOutput
}

这使您可以根据应用的给定安装在哪个 iOS 版本上运行适当地采取行动。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-17
    • 1970-01-01
    相关资源
    最近更新 更多