0

The thing is i am making a request that brings me back some images with different height that i want to autoresize each cell according to each image, but when i paint them in the tableview, show wrong cell height ias all of them has same size, until i scroll them. The matter is that i had put UITableViewAutomaticDimension, estimate, autolayout constraints are ok.. and so on. But as images are receiving 2 or 3 secs after tableview has been loaded, i cannot refresh tableview nor reload it.

Any idea how can i fix this problem?

BorjaCin
  • 172
  • 1
  • 1
  • 7

1 Answers1

-2

The table view needs to refresh the cell heights now. Calling beginUpdates() and endUpdates() will force the table view to refresh the heights.

tableView.beginUpdates()
// set your image in cell here 
tableView.endUpdates()

There is also pretty nice tutorial: Self-sizing Table View Cells

Tomasz Czyżak
  • 1,118
  • 12
  • 13
  • Thank you for this code snippet, which might provide some limited, immediate help. A proper explanation [would greatly improve](https://meta.stackexchange.com/q/114762/350567) its long-term value by showing why this is a good solution to the problem, and would make it more useful to future readers with other, similar questions. Please [edit] your answer to add some explanation, including the assumptions you've made. – iBug Dec 05 '17 at 10:35
  • 1
    This code result in multiple updates on cell, causing bugs on automatic scroll. No right solution for that question – Daniel Arantes Loverde Nov 07 '19 at 12:50