Aspect ratio "Scale To Fill" and "Aspect Fit" make the image stretched to whole UIImageView size. How can I use Aspect Fill" to handell UIImageView inside UITableViewCell. UIImageView inside UITableViewCell is running out of the screen in Aspect Fill. I want to make the image to take is original size rather then to stretch but I want to prevent it form overlapping over its lower cell. Rather its better if it goes below the lower cell.
First Scale To Fill Second Aspect Fill
I want to use Aspect Fill and gain as below:
I use following to select the image mode
My code
Cell.m
- (void)awakeFromNib {
_img.clipsToBounds = YES;
_img.contentMode = UIViewContentModeScaleAspectFill;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
}
VCUIViewController.m
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.section == 0) {
static NSString *CellIdentifier = @"NoticiasDetailImageCell";
NoticiasDetailImageCell *cell = (NoticiasDetailImageCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:CellIdentifier owner:self options:nil];
cell = (NoticiasDetailImageCell *)[nib objectAtIndex:0];
}
cell.img.image = self.img;
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
}