UIImageView in my UITableViewCell changes size on click
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.autoResizingMaskshould be set to
imageView.clipsToBoundsshould be set to
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:
tableView:willDisplayCell:forRowAtIndexPath:and set the
imageViewproperties there. If
imageView.frameis the problem, this likely won't fix it.
Add your own
UIImageViewto the cell configured how you want it and don't use the built in
imageViewproperty. 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.