UIImageView in my UITableViewCell changes size on click
If you have custom UITableViewCell then make sure that your UIImageView is not named with "imageView"
The only things that come to mind that effect the size & appearance of a view within its superview are:
Are you changing the frame/bounds/center properties anywhere? Where/how is the frame set initially?
imageView.autoResizingMask
should be set toUIViewAutoResizingNone
imageView.clipsToBounds
should be set toYES
EDIT: more suggestions
I'm shooting in the dark b/c your posted code looks fine and if you've set imageView.clipsToBounds
that should constrain the drawn image to the imageView
frame. Here are a couple more things to try:
Implement
tableView:willDisplayCell:forRowAtIndexPath:
and set theimageView
properties there. IfimageView.frame
is the problem, this likely won't fix it.Add your own
UIImageView
to the cell configured how you want it and don't use the built inimageView
property. If the behavior of the default cell is causing the problem this should work.
EDIT: large image problems
I don't know exactly how big the "really big images" are that you are currently using but they are likely the issue. From the UIImage
docs (emphasis is mine):
You should avoid creating UIImage objects that are greater than 1024 x 1024 in size. Besides the large amount of memory such an image would consume, you may run into problems when using the image as a texture in OpenGL ES or when drawing the image to a view or layer. This size restriction does not apply if you are performing code-based manipulations, such as resizing an image larger than 1024 x 1024 pixels by drawing it to a bitmap-backed graphics context. In fact, you may need to resize an image in this manner (or break it into several smaller images) in order to draw it to one of your views.
This answer helped me. But I had to make sure to call [cell layoutSubviews]
in the method that actually does the setting, like this:
cell.imageView.image = image;[cell layoutSubviews];
Hope this can be of use to you!