Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Orientation issue during animation with UIImageView as reference view #115

Closed
lrossi opened this issue Jan 9, 2016 · 3 comments
Closed
Labels

Comments

@lrossi
Copy link
Contributor

lrossi commented Jan 9, 2016

I have encountered an issue during the opening and closing animations when the following conditions are met:

  • Delegate's photosViewController:referenceViewForPhoto: returns an UIImageView.
  • The UIImageView's image is a photo taken with the device in portrait orientation (i.e. the UIImage has meaningful orientation informations associated).

If this is the case, the image is shown in the wrong orientation during the animation:
orientation-issue

Here you find a simple demo project reproducing the issue. The project is build against the latest iOS 9 SDK and I have tested it on iOS 8 & 9 devices with the same results.

By tracking down the issue, it seems to be related to the newAnimationViewFromView: method of NYTPhotoTransitionAnimator, and to the following lines in particular:

if (view.layer.contents) {
    animationView = [[UIView alloc] initWithFrame:view.frame];
    animationView.layer.contents = view.layer.contents;
    animationView.layer.bounds = view.layer.bounds;
    animationView.layer.cornerRadius = view.layer.cornerRadius;
    animationView.layer.masksToBounds = view.layer.masksToBounds;
    animationView.contentMode = view.contentMode;
    animationView.transform = view.transform;
}

When view is a UIImageView, its layer's contents is a CGImage and that seems to strip out the orientation information of the corresponding UIImage. By quick looking at the variables in the debugger, the resulting animationView appears to be rotated and doesn't look the same as the original view.

This is not an issue with UIImage-s that don't store meta-informations about their own orientation, but it seems to be a problem with—at least—portrait image taken from the device's camera.

At the moment I'm using a patch (that I am about to send as pull request) addressing UIImageView-s to overcome this problem. Here you find another version of the demo project with the patch applied.

Thanks!

cdzombak added a commit that referenced this issue Jan 26, 2016
Fix the use of tabs and add a comment explaining a workaround for #115
@cdzombak
Copy link
Contributor

closed by #116

@cdzombak cdzombak added the bug label Jan 26, 2016
@bcapps
Copy link
Contributor

bcapps commented Feb 2, 2016

I may be a little late to the game here, but I was not able to reproduce this issue with the sample project provided above using an iPhone 6 device on iOS 9. Is there something special required beyond the steps mentioned above?

@cdzombak
Copy link
Contributor

cdzombak commented Feb 2, 2016

@bcapps I just tried & am able to repro on iPhone 6S & latest iOS 9.2.x. Did you pick a photo which was taken on your device, in portrait orientation?

2016-02-02 14_46_30

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants