Reputation: 233
I have some difficulty in figuring out how to dynamically have each cell
resize according to the UIImage
and the other content inside the UIView
.
Heres a picture to better understand:
The grey background is the contentView
of the cell
.
The white on top is a UIView
.
Here is how I am downloading images:-
inside cellForRowAtIndexPath
cell.bigImageView.file = (PFFile *)object[@"image"];
[cell.bigImageView loadInBackground:^(UIImage * _Nullable image, NSError * _Nullable error) {
}];
Setting the height of the cell in heightForRow
according to the size of the cell from storyboard
return 535.0f;
Upvotes: 0
Views: 96
Reputation: 411
Provide the estimatedRowHeight
and rowHeight
of your tableView as
tableView.estimatedRowHeight = 100.0 // Your estimated height of the row
tableView.rowHeight = UITableViewAutomaticDimension;
while setting up your tableView
.
Update:
For top left image: Leading to UIView, Top, Trailing to button, Width and height For Button: Width, height, top, trailing to Label
For Bottom Button: leading to UIView, trailing to Label, Bottom to contentView, width, height
For ImageView: Leading to UIView, Trailing to UIView, Top to any of items above image View, bottom to "Bottom Button" or "Bottom Label". Set its width equal to content View. No Height, Set its content Hugging property to low.
Upvotes: 1
Reputation: 1067
// try like thhis
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
UIImage *img = // here load image
if (img) {
return img.size.height + // your additional static heght
} else {
return 350;// defaultHeght;
}
}
Upvotes: 0