【发布时间】:2017-07-28 12:07:16
【问题描述】:
当我在人像模式下拍照时,savedImage设置为UIImageView时会自动旋转。
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *filePath = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"ProfilePicture.png"];
[UIImagePNGRepresentation(image) writeToFile:filePath atomically:YES];
UIImage *savedImage = [UIImage imageWithData:[NSData dataWithContentsOfFile:filePath]];
但是当我使用UIImageJPEGRepresentation: writeToFile: atomically: 方法时,结果图像没有问题。
谁能解释为什么我在使用 UIImageJPEGRepresentation 而不是在 UIImagePNGRepresentation 中时没有得到正确方向的图像。
注意:我试过了
UIImage *imageToDisplay =
[UIImage imageWithCGImage:[originalImage CGImage]
scale:[originalImage scale]
orientation: UIImageOrientationUp];
保存imageToDisplay,但不工作
【问题讨论】:
标签: ios objective-c uiimageview uiimage