正在开发一个照片应用程序。相机图像正在自动改变方向iPhone
在这里,我使用图片库中的图片以及通过相机拍摄的图片并将其显示在图片视图中。
照片库中的图像以正确的方向出现,但相机图像以不同的方向显示。
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0]; // Get documents folder
NSString *dataPath = [documentsDirectory stringByAppendingPathComponent:@"MyFolder"];
NSString *imagePath = [dataPath stringByAppendingPathComponent:@"girl.jpg"];
if ([[NSFileManager defaultManager] fileExistsAtPath:imagePath]) {
UIImage *image = [UIImage imageWithCGImage:[UIImage imageWithContentsOfFile:imagePath].CGImage scale:bieberImage.image.scale
orientation:NO];
// bieberImage.transform = CGAffineTransformMakeRotation(1.57079633);
CABasicAnimation *crossFade = [CABasicAnimation animationWithKeyPath:@"contents"];
crossFade.duration = 3.0;
crossFade.fromValue = (id)bieberImage.image.CGImage;
crossFade.toValue = (id)image.CGImage;
[self.bieberImage.layer addAnimation:crossFade forKey:@"animateContents"];
}
谁能告诉我如何纠正这个问题。
在此先感谢。
,我已经试过,但还是相机中的图像不来正确的方向。 – ishhhh
有没有其他的替代 – ishhhh
看到上面的编辑 - 这应该旋转你的形象。 – Rayfleck