Amyga17 Amyga17 - 1 year ago 90
iOS Question

UIImageView.animationImages displaying images with rotation

I have a UIImageView that should animate an array of images called

. I have the animation set up like so:

imageView = [[UIImageView alloc] init];
imageView.frame = CGRectMake(0, 48, 320, 520);
imageView.animationImages = capturedImages;

imageView.animationDuration = 3.0;
imageView.animationRepeatCount = 0; //animate forever
[imageView startAnimating];

[self.view addSubview:imageView];

The images in capturedImages are taken with the phone/camera view upright. However, when the imageView displays them, they animate properly but are rotated 90 degrees counterclockwise. Is there a way to change the orientation of
, or do I have to set each image's orientation individually?

Answer Source

The simplest solution may be to just rotate the UIImageView itself.
You can use the transform property of UIView to do this:

[imageView setTransform:CGAffineTransformMakeRotation(M_PI_2)];

Be aware of the fact that this will break if you start displaying images which are already in the correct orientation. These will be rotated 90 degrees clockwise as well.