ios - UIImagePickerController 中的前置摄像头

标签 ios objective-c iphone swift uiimagepickercontroller

我正在使用 UIImagePickerController 开发 iPad2 中的前置摄像头应用程序。

当我捕获图像时,它显示为从左到右翻转。

如何纠正这个问题?

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];
<小时/>

编辑:添加了 swift 代码

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

关于ios - UIImagePickerController 中的前置摄像头,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38851706/

相关文章:

objective-c - 更新绑定(bind)到 NSArrayController 的表列

ios - 如何为 UITabBarItems 设置没有标题的图像?

iphone - GameCenter 功能崩溃应用程序 - 谁能帮忙解决?

ios - 在 Swift 中使用 multipart/form-data 上传图像和参数

ios - 有没有办法使用 gmail api 安排邮件?

ios - 如何使用 AutoLayout 让 UITableView header 的简单布局发挥作用?

iphone - FB Graph API 未进入横向模式

具有 2 个数据源/委托(delegate)的 iOS Tableview

ios - 在 iOS 7 推送通知中正确使用 "content-available"

iOS SDK 和 Instagram