是否可以以纵向拍摄所有照片?现在,如果我在风景中拍摄照片,它就是在风景中。尝试设置:
@objc private func handleTakePhoto() {
let photoSettings = AVCapturePhotoSettings()
if let connection = photoOutput.connection(with: .video) {
connection.videoOrientation = .portrait
}
photoOutput.capturePhoto(with: photoSettings, delegate: self)
}
func photoOutput(_ output: AVCapturePhotoOutput, didFinishProcessingPhoto photo: AVCapturePhoto, error: Error?) {
guard let imageData = photo.fileDataRepresentation() else {
return
}
let tempURL = URL(fileURLWithPath: NSTemporaryDirectory(), isDirectory: true).appendingPathComponent(UUID().uuidString)
do {
try imageData.write(to: tempURL)
onSelect?(tempURL)
return
} catch {}
onSelect?(nil)
}
但它没有帮助并尝试为 AVCaptureVideoPreviewLayer 设置 videoOrientation,但它又没有了。