正在初始化图像选取器
imagePicker.sourceType = UIImagePickerController.SourceType.camera
//If you dont want to edit the photo then you can set allowsEditing to false
imagePicker.allowsEditing = false
imagePicker.delegate = self
imagePicker.sourceType = .camera
imagePicker.cameraDevice = .front
imagePicker.cameraCaptureMode = .photo
// imagePicker.modalPresentationStyle = UIModalPresentationStyle.overCurrentContext
imagePicker.cameraOverlayView = nil
imagePicker.showsCameraControls = true
self.present(imagePicker, animated: true, completion: nil)
图像拾取器控制器的扩展
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
guard var image = info [.originalImage] as? UIImage else {
return
}
if picker.cameraDevice == UIImagePickerController.CameraDevice.front {
image = UIImage(cgImage: image.cgImage!, scale: image.scale, orientation:.leftMirrored)
} else {
print("back")
}
picker.dismiss(animated: true)
}
自拍相机拍摄的图像被翻转了。我们该如何解决这个问题?
1条答案
按热度按时间owfi6suc1#