saniaxxx26
saniaxxx26

Reputation: 472

UITableView and thumbnails

UITableView has UIImageView, all images has the same size. But when I starting scroll or selecting row, some images can change size. I cannot understand why. Or how to make an imageview of a fixed size in a table row?

enter image description here

Upvotes: 0

Views: 82

Answers (2)

Alex Andrews
Alex Andrews

Reputation: 1498

Use UIGraphicsImageContext with the table view cell image view like :

UIImage *thumbNail = [UIImage imageNamed:[_imageArray objectAtIndex:indexPath.row]];
// Setting thumbnail image
CGSize itemSize = CGSizeMake(60, 40);// Sample image size
UIGraphicsBeginImageContext(itemSize);
CGRect imageRect = CGRectMake(0.0, 0.0, itemSize.width, itemSize.height);
[thumbNail drawInRect:imageRect];
cell.imageView.contentMode = UIViewContentModeScaleAspectFill;
cell.imageView.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

Upvotes: 1

Suhail kalathil
Suhail kalathil

Reputation: 2693

You can do one thing.. Use custom cell and set imageView's frame there.

Upvotes: 0

Related Questions