Scenario:
I have a custom UITableViewCell
, and i have added a UIImageView
inside it. I can add width
, height
, top
, bottom
, trailing
, leading
, center vertically/horizontally
constraints
to it, but i want to add constraint for aspect ratio. Storyboard doesn't let me add constraint for aspect ratio with Content View of UITableViewCell, so to overcome it i added another view with constraints top, bottom, trailing, leading (constant = 0) and then made UIImageView
a subview of it and added aspect ratio constraint. After that i mentioned height of the cell using
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
return 60; // for example
}
This works fine.
Question: Is this the good approach or there is another way to address same Scenario?
P.S : I would have added screenshots but forum is not letting me