Downloading images from a URL in uiimage and then adding these images to uijimageview uitableviewcell, as shown below. I do not know the image sizes, but you need to make them be 40x40 in the tableviewcell image. Images save downloads with different widths in a uitableview.
Read other posts related to uiimage size / scaling, but these solutions do not work for me. I think because I use the uiimageview included in the uitableviewcell and create my own uiimageview.
Here's the code>
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [[UITableViewCell alloc] init]; ItemForSale *item = [listOfItems objectAtIndex:indexPath.row]; cell.textLabel.text = item.name; cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; cell.textLabel.font = [UIFont systemFontOfSize:14]; NSURL *url = [NSURL URLWithString: item.imgPath]; UIImage *thumbnail = [UIImage imageWithData: [NSData dataWithContentsOfURL:url]]; if (thumbnail == nil) { thumbnail = [UIImage imageNamed:@"noimage.png"] ; } cell.imageView.image = thumbnail; cell.imageView.contentMode = UIViewContentModeScaleAspectFill; cell.imageView.frame = CGRectMake(0, 0, 40, 40); cell.imageView.autoresizingMask = UIViewAutoresizingNone; cell.imageView.clipsToBounds = YES; return cell; }
I tried setting the content mode (I tried both options aspect and aspect), tried to reset the frame, installed autoresizingmask, clipTobound. none of this changed anything.
Augie
source share