I am trying to set an image to a UIImageView
of a SimpleTableCell
in a UITableView
. I have changed the size of the imageview, but whenever I try to set the image, it automatically resizes itself. I tried using the code here to resize the image and set it. But it only works when I set the image dimensions to (20x20) which is half of the size of the UIImageView
(40x40). So it comes out blurred. I also tried setting UIAspectRatioFit/UIAspectratioFill
and clipsToBounds = YES
. Nothing seems to work.
Another strange part is that the imageView
doesn't resize itself when I use an image directly downloaded from the web like so:
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
UIImage *userImage = [UIImage imageWithData:userImageData scale:self.profileImage.frame.size.height/self.profileImage.frame.size.width];
UITableViewCell *cell = [self.myTable cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]];
cell.imageView.image = userImage;
}
But then I store this image into a documents directory and then try to reload in elsewhere, the resizing occurs. Any solutions?