2

I am seeing some peculiar behavior in an iPad application. I have a UIImageView and I am capturing from the camera. When in Portrait mode and I take a picture it appears correctly in the UIImageView when I respond to the didFinishPickingMediaWithInfo event. However, when I return to the UIIMageView later to redisplay the saved photograph it automatically rotates the image 90 degrees. Rotating the device continues to show the image rotated 90 degrees.

Is there a way to determine the orientation used when the image is captured and is that the method that should be used to re-display the image?

Any help would be appreciated. I searched but could not find anything specific to this.

Robert Hill
  • 323
  • 1
  • 8
  • 16
  • Please post the code that you are using to save the photo and to redisplay it so that we know where your problem might lie.... – lnafziger Mar 01 '13 at 22:22
  • Try taking pictures with the iPod in different orientations (like portrait upside down) to see how that affects the behavior. Look at the imageOrientation property of the UIImage you create from the saved image. I believe you'll discover that the images are store rotated. If you'll post how you save and then get the images (e.g. are they files in the sandbox or ALAssets in the photo library?) then perhaps someone can offer more help about rotating them. – Charlie Price Mar 01 '13 at 23:24
  • 1
    Orientation information can stored in the image's EXIF data - UIImageView will attempt to respect that. This thread covers the issue quite well : http://stackoverflow.com/questions/5427656/ios-uiimagepickercontroller-result-image-orientation-after-upload – TimD Mar 02 '13 at 00:06

2 Answers2

2

I'm all set with this. The responses at

iOS UIImagePickerController result image orientation after upload

worked for me. Immediately after capturing the image I'm checking the rotation and adjusting as necessary per the code example on this thread.

Thanks for all that responded!

Community
  • 1
  • 1
Robert Hill
  • 323
  • 1
  • 8
  • 16
-3

Try this: add this to viewWillAppear or wherever you desire:

[self updateLayoutForNewOrientation: self.interfaceOrientation];

and add this method:

- (void) updateLayoutForNewOrientation: (UIInterfaceOrientation) orientation {
if (UIInterfaceOrientationIsLandscape(orientation)) {
// do something
    } else {
//do something
   }
}
Obj-Swift
  • 2,802
  • 3
  • 29
  • 50