2

I'm currently building an app that uses a collection view showing images, among other stuff, inside cells.

The controller dequeues a cell, sets an image, and calls a method to change the frame of the image.

I change the image position and size like so:

[imageView setFrame:CGRectMake(imageViewXOrigin,
                                  imageViewYOrigin,
                                  imageViewWidth,
                                  imageViewHeight)];

This is after calculating all 4 values.

After that, the controller returns the cell, and it gets drawn on screen.

The problem is that it's drawn using the old dimensions, and only after scrolling the cell out of the screen and scrolling it back in again will it display correctly. How do I fix this?

Using a standard storyboard mode is out of the question, because I want the image to be an aspect fit bottom left, which can't be accomplished by using the storyboard.

How do I fix this?

Cezar
  • 55,636
  • 19
  • 86
  • 87
Nico Griffioen
  • 5,143
  • 2
  • 27
  • 36
  • have you fixed your problem with my answer? if yes plz can accept it? – Mirko Catalano Oct 21 '13 at 16:03
  • I had identical situation, but with the UILabel frame. What we wanted is to resize the frame so that the text is always aligned to top of label. We couldn't make it to work in code, but once we used autolayout instead everything run smoothly. Also aligning to top is easy in autoloayout once you know the solution. For the image problem maybe this post will be helpful http://stackoverflow.com/questions/16878607/change-uiimageview-size-to-match-image-with-autolayout – Michał Kreft May 28 '14 at 08:47

0 Answers0