UIActivityViewController rotates UIImages with different imageOrientations
| Originator: | testuttech | ||
| Number: | rdar://12034547 | Date Originated: | Sun, 05 Aug 2012 12:05:42 GMT |
| Status: | Open | Resolved: | |
| Product: | iPhone SDK | Product Version: | 6.0 Beta 3 |
| Classification: | Other bug | Reproducible: | Always |
Summary: Under certain conditions, when UIImages (or NSDatas containing image data) are passed to a UIActivityViewController, they will be in the wrong orientation when choosing to email them, share them, or do anything else with them. When passing a UIImage with an imageOrientation other than UIImageOrientationUp, the image will appear rotated incorrectly when emailing, or when posting to Facebook, or when assigning to a contact, etc. However, if you supply an NSData with image data, all UIActivities will have the image rotated in the correct orientation (Except UIActivityTypePostToFacebook, which will have the image rotated incorrectly if the image is over a certain size. That's another bug, radar number in appended information.) Steps To Reproduce: Create a UIActivityViewController, and pass it a UIImage with an imageOrientation other than UIImageOrientationUp as an activityItem. Select "Mail" from the UIActivities, and a mail composer will appear, with the image rotated incorrectly in the message body. Expected Results: The image is in the same orientation as the image that was passed into the UIActivityViewController Actual Results: The image is rotated as if it has no imageOrientation. Regression: This only happens when the activityItem is a UIImage. When passing in an NSData representation of the image with the correct orientation, all the UIActivities will have the image rotated correctly. Notes: It seems when the system converts the UIImage into an NSData for the MFMailComposeViewController (and other UIActivities) it does NOT preserve the orientation information. This is why when an NSData is passed in, it is rotated correctly as the system doesn't have to convert it. Included is a sample app which demonstrates this issue. This must be run on an iPad with a camera on iOS 6. First, launch the app and then tap the "Take Picture" button. Take a picture with the device in the orientation UIDeviceOrientationPortrait, UIDeviceOrientationLandscapeLeft, or UIDeviceOrientationLandscapeRight, and then once you're done tap the action button at the bottom of the screen. Tap any of the UIActivities (except Facebook, as that has another orientation bug associated with it, radar number in appended information.), and see the image rotated incorrectly. Then, go into the ViewController.m file, and comment out the line: #define kUseUIImageAsActivityItem Now, when you repeat the steps as before, it'll pass an NSData to the UIActivityViewController. When you tap on any of the activities (again, except for Facebook), the image will be rotated correctly.
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!