我正对着应用程序中的iPad2使用前UIImagePickerController摄像头进行冲洗.

当我拍摄图像时,它显示为从左向右翻转.

我该如何纠正这一点?

if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) 
    {
        UIImagePickerController *imgPkr = [[UIImagePickerController alloc] init];
        imgPkr.delegate = self;
        imgPkr.sourceType = UIImagePickerControllerSourceTypeCamera;
        imgPkr.cameraDevice=UIImagePickerControllerCameraDeviceFront;


        UIImageView *anImageView=[[UIImageView alloc] initWithImage:[UIImage imageNamed:[NSString stringWithFormat:@"select%d.png",val]]];
        anImageView.frame = CGRectMake(0, 0, anImageView.image.size.width, anImageView.image.size.height);
        imgPkr.cameraOverlayView = anImageView;
        [theApp.TabViewControllerObject presentModalViewController:imgPkr animated:YES];
        [imgPkr release];
    }

推荐答案

您可以使用此选项从源图像翻转图像

UIImage *flippedImage = [UIImage imageWithCGImage:picture.CGImage scale:picture.scale orientation:UIImageOrientationLeftMirrored];

Edit:新增swift代码

let flippedImage = UIImage(CGImage: picture.CGImage, scale: picture.scale, orientation:.LeftMirrored)

Swift相关问答推荐

SwiftUI加载器未覆盖UIKit导航设置中的导航栏

try 编写复杂的断言时出现编译器错误

具有@Published属性的双向数据流动,能够忽略事件

自定义完整屏幕封面动画

减go 用SWIFT struct 填充的NSCountedSet

如何使用AsyncTimerSequence获取初始时钟,然后在指定的时间间隔内开始迭代?

Swift UI中视图上的值未更新

有没有一种方法可以访问封闭实例ObservableObject以从属性包装器中的任何位置调用objectWillChange.send()

标有@MainActor 的函数中的异步调用是否也在主线程上运行?

如何打印出此 struct 中的数据?

如何删除 macOS 中的所有命令?

SwiftUI View .tint(_ Color) 方法不起作用

故事板未在助手中显示视图控制器

如何在 Swift 中将 XPC 自定义类列入白名单?

调用从 SwiftUI 视图传递到 PageViewController.Coordinator 的函数

用于 Swift 编码的 iOS 应用程序的 Ffmpeg

调整文本的字体大小以适应 UIButton

在 Swift for iOS 中沿圆形路径绘制文本

如何在Swift中找出字母是字母数字还是数字

无法停止 AVPlayer