Anthony Anthony - 1 month ago 5
iOS Question

swift 3 - dynamic cells size issue

i'm trying to create a table with many dynamic cells prototype
i'm using the 2 lines of codes in the viewDidLoad()

Table.estimatedRowHeight = 171;
Table.rowHeight = UITableViewAutomaticDimension


however, when the cells need to be higher than 171, it stays 171, until i scroll down and up my tableview, then every cell takes it own really height

so what is the really problem ?

Answer

The code is correct, the location is not.

You should not be giving it in viewDidLoad but rather heightForRowAtIndexPath

Try that, it should work. Cheers!