iOS 多摄像头访问一次仅对两个摄像头执行

时间:2021-01-21 07:21:57

标签: ios swift camera avcapturesession

对于 iPhone Xs MAX,我一次只能预览两个摄像头。这三个动作不能同时执行

guard self.camManager.setUpCamera(type: .builtInWideAngleCamera, position: .front, outputViewlayer: self.frontLayer!) else{
            DispatchQueue.main.async {
                let alertController = UIAlertController(title: "Error", message: "issue while setuping front camera", preferredStyle: .alert)
                alertController.addAction(UIAlertAction(title: "OK",style: .cancel, handler: nil))
                self.present(alertController, animated: true, completion: nil)
            }
            return
        }
        
    guard self.camManager.setUpCamera(type: .builtInWideAngleCamera, position: .back, outputViewlayer: self.backLayer1!) else{
        DispatchQueue.main.async {
            let alertController = UIAlertController(title: "Error", message: "issue while setuping back camera", preferredStyle: .alert)
            alertController.addAction(UIAlertAction(title: "OK",style: .cancel, handler: nil))
            self.present(alertController, animated: true, completion: nil)
        }
        return
    }
    
    guard self.camManager.setUpCamera(type: .builtInTelephotoCamera, position: .back, outputViewlayer: self.backLayer2!) else{
        DispatchQueue.main.async {
            let alertController = UIAlertController(title: "Error", message: "3rd camera", preferredStyle: .alert)
            alertController.addAction(UIAlertAction(title: "OK",style: .cancel, handler: nil))
            self.present(alertController, animated: true, completion: nil)
        }
        return
    }

这里,如果前两个工作正常,长焦相机将无法工作。

0 个答案:

没有答案