0
MenuTableView.RowHeight = UITableView.AutomaticDimension;
MenuTableView.EstimatedRowHeight = 100;

For a cell I use AutoLayout. Everything is pinned to everything. It properly calculates size, but when I try to change dynamically height constraint of the textfield to 0 for example cell isn't updating its height(doesn't shrink) as it would do initially if I changed the same constraint in the editor.

All constraint changes work good if they are done in GetCell but not when later dynamically

How to update cell dynamically? Or how to trigger cell height recalculating based on views and constrains?

Vorotnyak_Nazar
  • 894
  • 1
  • 10
  • 22
  • 1
    Use stackview in the cell. Add textfield as subview to stackview. Whenever you hide/show the textfield cell height will be automatically changed. – RajeshKumar R Dec 29 '17 at 13:57
  • Maybe helpful https://stackoverflow.com/questions/18746929/using-auto-layout-in-uitableview-for-dynamic-cell-layouts-variable-row-heights – ColeX Jan 01 '18 at 02:23

1 Answers1

1

To update cell, use tableView.reloadRows(at:with) method after you have changed something in that cell

dduyduong
  • 124
  • 1
  • 5
  • It's not what I want. To use reloadRows I would need to store cell state in the data model. Data is just data, there should not be any state variables. Changes i make in the cell are not regarding data. for example I need to show|hide some "details" section in the cell on button click that also in the cell. – Vorotnyak_Nazar Dec 29 '17 at 14:28
  • You can show/hide anything in that cell, but the only way to change the cell height is to reload the table view (using reloadRows or any reload functions from table view) – dduyduong Dec 30 '17 at 06:44