Detect existence of camera in iPhone app?

前端 未结 8 736
逝去的感伤
逝去的感伤 2020-12-23 15:49

I\'m writing an iOS app, and I need to be able to detect if the device has a camera. Previously, I would check if the device is an iPhone or not, since only the iPhone has a

8条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-23 16:41

    You can check for availability of a specific source type using discovery session (Swift 5):

    let discovery = AVCaptureDevice.DiscoverySession.init(deviceTypes: [.builtInWideAngleCamera], mediaType: AVMediaType.video, position: .back)
    let isWideAngleCameraSupported = !discovery.devices.isEmpty
    

提交回复
热议问题