UITableViewCell does not set according to text/components after using UITableViewAutomaticDimension

To overcome this issue we have to set layout of the cell after inserting any values into cell.

Refer below code:

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
CustomTableViewCell *cellCustom = (CustomTableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cellCustom == nil)
{
cellCustom = [[CustomTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}

// Write your code here for inserting text/component and than follow below code:

cellCustom.layoutIfNeeded()
return cellCustom;

}

You may also like

Leave a Reply