nicklockwood / AsyncImageView

[DEPRECATED]
http://charcoaldesign.co.uk/source/cocoa#asyncimageview
Other
906 stars 186 forks source link

Update ImageView frame when the loading completes #6

Closed bolshas closed 12 years ago

bolshas commented 12 years ago

Hi,

I am trying to display the image in a UIScrollView and therefore need to update the contentsize and the bounds of the imageview to the actual size of the image being loaded.

I have implemented the [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(imageLoaded:) name:AsyncImageLoadDidFinish object:nil];

and in this method imageLoaded I am trying to update the frame of the imageview.

The problem is that sometimes it updates, and sometimes not (i. e. sometimes the bounds stay the same as the dummy image's).

Since the images are loaded from the outside, their dimensions are often not known. Perhaps you could suggest how the holding view frame could be updated to match the size of the downloaded image?

Andrius

nicklockwood commented 12 years ago

Sorry I didn't reply sooner, I somehow missed your comment. You can monitor when the image property is set using KVO (Key Value Observing) and the set the image frame to match the image.size.