I have a UIImageView that is loaded with images from a document directory in the ios file system.
The problem is that when I call
[imageView sizeToFit]
This does not work. I think this is due to the fact that the image did not load completely to this point, and therefore part of sizeToFit is called before it has the width and height of the image.
Can someone point me towards correction, please.
Here is my code:
imageView.contentMode = UIViewContentModeScaleAspectFit;
imageView.image = [UIImage imageWithContentsOfFile:[FileOperations getLibraryPath:[NSString stringWithFormat:@"%d.png", listData.imageId]]];
[imageView sizeToFit]
[imageScroll setContentOffset:CGPointMake(0, 0)]
imageScroll.contentSize = imageView.frame.size;
imageScroll.decelerationRate = UIScrollViewDecelerationRateFast;
imageScroll.minimumZoomScale = 1;
imageScroll.maximumZoomScale = 2;
[imageScroll setZoomScale:imageScroll.minimumZoomScale]
[imageScroll addSubview:imageView]
Thanks Ashley
source
share