每次我使用相机拍摄照片并保存时,图片总是横向的。这意味着我在Xib中的UIImageView方向是错误的。它应该是纵向的,这也是我所期望的。我可以通过将图像旋转90度来更正这个问题,但即使这样,我也无法禁用动画来显示原始的横向照片,以及接下来的旋转动画本身。如何确保从相机获取的UIImageView实际上处于纵向模式而不是横向模式,并且如何在CGAffineTranformationMakeRotation期间禁用动画?
http://www.platinumball.net/blog/2009/03/30/iphone-uiimage-rotation-and-mirroring/
然后,一旦实现了该类别,您可以执行以下操作:- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
UIImage *originalImage, *editedImage, *rotatedImage;
editedImage = (UIImage *)[info objectForKey:UIImagePickerControllerEditedImage];
originalImage = (UIImage *)[info objectForKey:UIImagePickerControllerOriginalImage];
if (editedImage)
{
rotatedImage = [editedImage rotate:UIImageOrientationRight];
}
else
{
rotatedImage = [originalImage rotate:UIImageOrientationRight];
}
NSString *f = @"/set/this/to/your/file/name";
[UIImagePNGRepresentation(rotatedImage) writeToFile:f atomically:YES];
[[picker parentViewController] dismissModalViewControllerAnimated:YES];
[picker release];
}