You can make your UIImageView size according to the image you are loading, but it will look bad .
So, I suggest you make all your images the same size, so it will look beautiful and sweet
You can use this to make the whole image the same size.
+ (UIImage *)imageScaledToSizeWithImage:(UIImage *)imagewww andsizeee:(CGSize)size { //avoid redundant drawing if (CGSizeEqualToSize(imagewww.size, size)) { return imagewww; } //create drawing context UIGraphicsBeginImageContextWithOptions(size, NO, 0.0f); //draw [imagewww drawInRect:CGRectMake(0.0f, 0.0f, size.width, size.height)]; //capture resultant image UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); //return image return image; }
But if you really want to show a table with a different row size, then make changes to the row size at runtime
when you get the image, then save your image in the dictionary with the indexPath key string value.
[tableImageDict setObject:image forKey:[NSString stringWithFormat:@"%i,%i",indexPath.row,indexPath.section]];
and then reload the table.
[table reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationNone];
It will change the height of the line
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { UIImage *image = (UIImage *)[tableImageDict objectForKey: [NSString stringWithFormat:@"%i,%i", indexPath.row,indexPath.section]]; if (image != nil) { return image.size.height; } else{ return 44.0; } }
Rajneesh071
source share