iosswiftuitableviewsnapkit

UITableViewCell remake constraints when reuse problem


I have a problem with reusing a cell.

In my cell there is a view that changes the constraints depending on its state. By default, cell height = 0, when the user clicks on the button, it changes its constraints top, leading, trailing and bottom. The problem is that if I expand, press expand view in one cell, scroll down (or up), then another cell will also be expanded.

I change the variable responsible for uncovering the cell in the prepareForReuse method, and it doesn't help :(

My solution used to be like this: I redid the constraints in the configure method (it is called in the cellForRow method in VC), and it worked, BUT there were lags when scrolling, apparently, because I change the constraints every time a cell is configured and reused Are there ways to avoid lag when scrolling? Is there another way to do this?

I use SnapKit for make layout.


Solution

  • I solved the problem by dividing the states into different cells