0
UIImage *rotatedImage = [UIImage imageWithCGImage:[img CGImage] scale:1.0 orientation:imageView.image.imageOrientation];
// Setting img to imageview
[imageView setImage:rotatedImage];

Above is code which works perfectly fine in iOS 6, but does not rotate the image in iOS 7.

I am getting the correct values for imageOrientation but still image does not rotate.

Any idea why?

Thanks.

Andrea
  • 26,120
  • 10
  • 85
  • 131
subhash Amale
  • 325
  • 3
  • 4
  • 14

1 Answers1

0

I think there is a logical error with "imageView.image.imageOrientation" property. There can be two scenarios that you need to check

  1. imageView.image should not be nil, otherwise, rotating image will not work and will return the image with same orientation.

  2. "imageView.image" and "img", both UIImage variables point to same image reference. Hence, the output is same.

I hope this can resolve your problem. Thanks!!

Basil
  • 44
  • 2
  • But why this could be a logical problem in only iOS 7 and not in iOS 6 – subhash Amale Nov 15 '13 at 10:00
  • Subhash, is it possible to provide more code snippet before this line of code where i can see something about imageView.image? – Basil Nov 15 '13 at 10:09
  • Basil, I have a scrollView which has UIImageViews.User scrolls through images horizontally.Once the imageview goes off screen I am setting its image as nil and again when it comes on screen I set its image from my dictionary of image names. So when I am reading imageView.image the image of that image is nil. But still it works in iOS 6. – subhash Amale Nov 15 '13 at 10:27