在Swift 2.0中,layerWithSession不可用?

时间:2015-09-19 19:17:17

标签: swift

您好我有AVCaptureVideoPreviewLayer

的问题
let previewLayer: AVCaptureVideoPreviewLayer = AVCaptureVideoPreviewLayer.layerWithSession(captureSession) as AVCaptureVideoPreviewLayer
    previewLayer.frame = UIScreen.mainScreen().bounds
    previewLayer.videoGravity = AVLayerVideoGravityResizeAspectFill
    visageCameraView.layer.addSublayer(previewLayer)
  

'layerWithSession'不可用:使用对象构造'AVCaptureVideoPreviewLayer(session:)'

1 个答案:

答案 0 :(得分:5)

正如错误消息所示,您必须

let previewLayer = AVCaptureVideoPreviewLayer(session: captureSession)