I've stack view inside table cell which contains three views. I want the stack view to adjust itself when one or two views are hidden. My issue is exactly as described in below questions except that my stack view is inside table cell. The solution mentioned in these threads don't work for me. See screenshot below for the exact problem.
Stack view is pinned to all sides and distribution is fill equally.
How do we make it work?
UIStackView shift content to left when inner views are hidden
UIStackView Distribution Fill Equally
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
guard let cell = tableView.dequeueReusableCell(withIdentifier: "tableCellID", for: indexPath) as? TableViewCell else {
fatalError("Can't find cell")
}
let profile = array[indexPath.row]
if profile.status {
cell.view2.isHidden = false
} else {
cell.stackViewTrailing.constant += cell.view2.frame.size.width
cell.view2.isHidden = true
}
return cell
}