How to increase tableViewCell height when increasing UiImageView height within the cell?

I am banging my head around this issue for quite a time.

I have a

UITableViewCell
that contains a UIStackView which contains inside of it 2
UIImageView's
.:

The UISTackView has it's trailing, leading and top space pinned to the Content View and the Content View height is equal to it's UISTackView.


Now the way it works is that when I slide with my finger on one of the pictures, that picture should expand it's width to the other side of the screen and it's height should enlarge to the size of the expanded width to make it even (I am using

UIPanGestureRecognizer
), which requires the
UITableViewCell
to enlarge too.


But for some reason even thought Content View height is equal to it's UISTackView, I have not managed to accomplish this presumably simple task. and although the

UiImageView's
are enlarging as I want, but the UITableViewCell height - remains static. which results in pushing the bottom of the cell out of the cell frame and causing it to hide

Based on suggestions to similar questions asked in stack overflow, I have tried the following, yet I still cannot resolve the issue.

I have added the following snippet of code in my

viewDidLoad()
:
tableView.rowHeight = UITableViewAutomaticDimension
tableView.estimatedRowHeight = 470


Likewise, I have added :

tableView.beginUpdates()
tableView.endUpdates()


What am I missing here?

Replies

One way is to relead the table when you hit the image, with the specific cell with bigger height.


see details here:

https://stackoverflow.com/questions/39673583/uitableview-change-cell-height-dynamically-when-clicked-the-custom-button

Try removing the equal heights constraint and instead using a vertical space constraint from the bottom of the stack view to the bottom of the content view. It’s my understanding that it needs an unbroken chain of constraints in order to correctly resize. Logically setting equal heights seems like it should have the same effect, but sizing of cells is picky.


Also, does it do the same if you don’t use a stack view?

Thare was a somehow similar question here

https://forums.developer.apple.com/thread/110975


Use func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath)