我有以下问题。
我制作了一个人们可以上传图片的应用程序,但我希望图片的上传方式与图片一样。现在,当我拍照时,它已经上传了90度。我从来没有说它必须转向。我试过像:
这样的东西int angle = 0;
switch(image.imageOrientation)
{
case UIImageOrientationUp:
angle = 0;
break;
case UIImageOrientationDown:
angle = 180;
break;
case UIImageOrientationRight:
angle = 90;
break;
case UIImageOrientationLeft:
angle = -90;
break;
}
UIImageView *iv = [[UIImageView alloc] initWithImage:image];
if (angle == 180)
{
NSLog(@"180");
degrees = 180;
radians = degrees / 57.2958;
iv.center = CGPointMake(0, 0);
iv.transform = CGAffineTransformMakeRotation(radians);
}
else if (angle == 90)
{
NSLog(@"90");
degrees = 90;
radians = degrees / 57.2958;
iv.center = CGPointMake(0, 0);
iv.transform = CGAffineTransformMakeRotation(radians);
}
else if (angle == -90)
{
NSLog(@"-90");
degrees = 270;
radians = degrees / 57.2958;
iv.center = CGPointMake(0, 0);
iv.transform = CGAffineTransformMakeRotation(radians);
}
else if (angle == 0)
{
NSLog(@"0");
degrees = 0;
radians = degrees / 57.2958;
iv.center = CGPointMake(0, 0);
iv.transform = CGAffineTransformMakeRotation(radians);
}
但这不起作用。有人可以帮我弄这个吗?
TLDR;如何检查图像的旋转方式并以正确的方式旋转图像?或者这是我要在图像显示的地方做的事情?
编辑:之后尝试在UIImageView中执行此操作,但这不起作用