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

Portrait images mangled on 7.1 #2

Open
2fours opened this issue Mar 26, 2014 · 19 comments
Open

Portrait images mangled on 7.1 #2

2fours opened this issue Mar 26, 2014 · 19 comments

Comments

@2fours
Copy link

2fours commented Mar 26, 2014

On 7.1 portrait images appear mangled. I'm setting alignTop and alignLeft to YES.

ios simulator screen shot mar 26 2014 11 07 07 am
ios simulator screen shot mar 26 2014 11 07 01 am

@reydanro
Copy link
Owner

I will look into it.
It seems as though the container UIImageView also has an image (in addition to the inner image view).

@reydanro
Copy link
Owner

Funny - I was able to replicate the issue the first time I ran the demo project on my iPad (7.1). Did a quick fix, and the issue disappeared. Then I removed the fix because I wanted to be positive, but now I can't reproduce the issue anymore.

I'm trying everything:

  • clean install of the app on the device
  • run in debug/release
  • fresh checkout from github
    I just can't get the bug back.

Do you get the bug 100% of the time? Did you try to clean the project or delete the app from the device and do a clean deploy?

Since I can't reproduce the bug, I can't know for sure that my small fix actually worked.
What I did was to force setting super.image = nil; in the setImage: method (force the container image to be nil, although technically it should be set to nil in the commonInit).

@2fours
Copy link
Author

2fours commented Mar 26, 2014

It happens for me every time in the simulator. Setting super.image = nil doesn't fix it for me.

@reydanro
Copy link
Owner

Ok, I will try in the simulator.

@2fours
Copy link
Author

2fours commented Mar 26, 2014

I should say it happens every time with my app. Let me try the demo project.

@2fours
Copy link
Author

2fours commented Mar 26, 2014

Confirmed that it happens for me in simulator with example project.

@reydanro
Copy link
Owner

True, I also get it in the simulator, but on the iPhone.
The iPad simulator works ok for me - can you give it a try just to see we are both getting the same behaviour?

Anyway, I will find the bug and come back.

@2fours
Copy link
Author

2fours commented Mar 26, 2014

Looks like it works ok in iPad simulator, jacked in iPhone simulator. Weird.

@reydanro
Copy link
Owner

Indeed. It is happening only in the iPhone 5 simulator (4 inch). The iPhone4 simulator works ok.
This really has my attention now :)

@reydanro
Copy link
Owner

-Ignore this comment, there is a better solution below-

I played with the bug a little more, and it's a tough one. I've had several solutions, but all of them had some shortcomings on how transparent the class remained - I want it to work just like a normal UIImageView works.

My best guess is that internally, the UIImageView now calls the image property instead of the underlying ivar when deciding whether/what to draw. Since that getter is overwritten so that you can access the inner UIImage from outside of the class, I basically always return a proper image to the container UIImageView.

You can find a fix in the new branch called fix_iphone5_ios7_1.
To fix it I overwrite the -layer method and return nil in it. This seems to disable the drawing for the container view.
I don't like it as a permanent solution since I think it can cause some crashes in the future. I'm still trying to think of a find a better solution to stop the container UIImageView from drawing, since it's obvious that setting the container image to nil is useless.

@reydanro
Copy link
Owner

I GOT IT!!! :)
Never mind my previous comment, I now have a good, stable fix.
You can find it on the master branch.

All I had to do is reset the self.layer.contents property on each layoutSubviews. Apparently it refreshes the contents from the image property (which I overwrote).

Thanks for spotting the problem and reporting it!

@2fours
Copy link
Author

2fours commented Mar 27, 2014

Great work thanks for fixing it in short time!

@reydanro
Copy link
Owner

Glad to hear it works on your end too. I will now close this thread.

@2fours
Copy link
Author

2fours commented Apr 3, 2014

There's still a problem here...things work fine until the image is clicked on, then the same issue re-occurs.

photo 6

@reydanro
Copy link
Owner

reydanro commented Apr 3, 2014

How do you click on the Image?
Do you use a Tap Gesture Recognizer or something similar?

@reydanro reydanro reopened this Apr 3, 2014
@2fours
Copy link
Author

2fours commented Apr 3, 2014

@reydanro
Copy link
Owner

reydanro commented Apr 3, 2014

Ok, I'll take a look at it. Hopefully I will be able to replicate this in a test project.
Thanks for pointing these things out :)

@2fours
Copy link
Author

2fours commented Apr 16, 2014

Any progress on this?

@sebhopley
Copy link

I had this issue as well, it seems to be that when the UITableViewCell is highlighted on selection it redraws the layer and when its un-highlighted it redraws the layer.
I solved it by doing this in the UITableViewCell:
- (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated
{
[super setHighlighted:highlighted animated:animated];
self.alignedImageView.layer.contents = nil;
}
I noticed that you've done this in the UIAlignedImageView, but it doesn't appear to work there

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

No branches or pull requests

3 participants