给出iOS风景照片时,CGImage不会旋转

时间:2015-08-11 06:45:07

标签: ios iphone swift

这行代码的哪一部分阻止图像以正确的方式旋转?当我用iOS设备横向拍照时,生成的UIImage不会正面向上旋转......

UIImageJPEGRepresentation(UIImage(CGImage: image.CGImage, scale: 0.2, orientation: UIImageOrientation.Up), 0.1)

1 个答案:

答案 0 :(得分:0)

下面我使用了选择图像格式选择器的代码并在4个方向上旋转。我选择的图像是iphone模拟器的默认格局,即 UP

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
 [picker dismissViewControllerAnimated:YES completion:nil];
[picker removeFromParentViewController];      
UIImage *upimage=[UIImage imageWithCGImage:[[info objectForKey:UIImagePickerControllerOriginalImage] CGImage] scale:0.2 orientation:UIImageOrientationDown];

crop.adjustedImage=[UIImage imageWithData:UIImageJPEGRepresentation(upimage, 0.2)];


[self presentViewController:crop animated:YES completion:nil];
}

<强> LEFT

enter image description here

<强> DOWN

enter image description here

从右

enter image description here

<强> UP

enter image description here