사진 앱을 개발 중입니다.카메라 이미지가 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"];
}
누구든지이 문제를 어떻게 해결할 수 있습니까?
미리 감사드립니다.
UIImage *image = [UIImage imageWithCGImage:[UIImage imageWithContentsOfFile:imagePath].CGImage scale:bieberImage.image.scale
orientation:NO];
으로 :
UIImage *image = [UIImage imageWithCGImage:[UIImage imageWithContentsOfFile:imagePath].CGImage scale:bieberImage.image.scale
orientation:UIImageOrientationRight];
편집 :
올바른 방향으로. – ishhhh
다른 대안이 있습니다 – ishhhh
위의 수정을 참조하십시오 - 이미지를 회전해야합니다. – Rayfleck