我正在尝试打开前置摄像头以便进行自拍并将其保存为输出,以便用户在提交之前能够看到图片。我配置的原始功能在iOS 10下折旧。 有人可以帮助理解如何正确地写这个吗?
http://example.com/controller/phpinfo
答案 0 :(得分:0)
class func `default`(_ deviceType: AVCaptureDevice.DeviceType,
for mediaType: AVMediaType?,
position: AVCaptureDevice.Position) -> AVCaptureDevice?
因此default
方法返回一个可选的AVCaptureDevice
。
您只需要替换
//NEW CODE:
let devices = AVCaptureDevice.default(.builtInWideAngleCamera, for: AVMediaType.video, position: .front)
)
for device in devices {
if device.position == AVCaptureDevice.Position.front {
带
//NEW CODE:
if let device = AVCaptureDevice.default(.builtInWideAngleCamera, for: AVMediaType.video, position: .front) {