Search code examples
iphoneiosresizeimageviewscale

AsyncImageView with fixed with but dynamic height?


I use the aSyncImageView to display images that is downloaded from a URL - The images have all kinds of different sizes but i need to display the image with a fixed width of 300 points but i need the height of the imageView to be dynamic - How do i do that?

I've looked at different resizingmasks but they all just fit the image within a fixed frame size - But i need the frame height to be dynamic since the picture height can wary by several hundred points. The problem is that i need to set a fixed width and height when setting the frame.

AsyncImageView *newsArticleImage = [[AsyncImageView alloc] init];
[newsArticleImage loadImageFromURL:[NSURL URLWithString:[newsResultSet stringForColumn:@"image"]]];
newsArticleImage.frame = CGRectMake(10, (newsArticleDateLabel.frame.origin.y + newsArticleDateLabel.frame.size.height + 5), 300, 50);
newsArticleImage.autoresizingMask = UIViewAutoresizingFlexibleHeight;

Solution

  • Doesn't seem to be possible without altering ASyncImageView or handling it with an observer.