i have implemented AFNetworking to async download the images to my table, everything works fine, but when i scroll down the table the image in the cell shrinks.
my code look like this:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];
NSDictionary *dictionary = [self.json objectAtIndex:indexPath.row];
cell.textLabel.text=[dictionary objectForKey:@"name"];
cell.detailTextLabel.text = [dictionary objectForKey:@"description"];
NSString *path = [[[[dictionary objectForKey:@"images"] objectAtIndex:0] valueForKey:@"thumb"] valueForKey:@"url"];
NSString *ruta = [NSString stringWithFormat:@"http://18.221.78.126/ecoferia%@",path];
NSURL *url = [NSURL URLWithString:ruta];
[cell.imageView setImageWithURL:url
placeholderImage:[UIImage imageNamed:@"placeholder.png"]];
return cell;
}
here are some screenshots:
any tips will be vary apreciate. regards.
There are different type of content mode available for image view in ios
For Example,
1) The option to scale the content to fit the size of the view by maintaining the aspect ratio. Any remaining area of the view’s bounds is transparent.
cell.imageView.contentMode = UIViewContentModeScaleAspectFit;
2) The option to scale the content to fill the size of the view. Some portion of the content may be clipped to fill the view’s bounds.
cell.imageView.contentMode = UIViewContentModeScaleAspectFill;
3) The option to scale the content to fit the size of itself by changing the aspect ratio of the content if necessary.
cell.imageView.contentMode = UIViewContentModeScaleToFill;
For further details you can refer, Apple Documentation