objective-cuitableviewnslayoutconstraintios-autolayoutuitableviewautomaticdimension

Wrong UITableViewCell height for some cells at first loading


I am using UITableViewAutomaticDimension to calculate height for my table view cell. It works fine for me. But for some cells, the height returned is 44 rather than dynamically calculating height. But on scrolling up an looking back to the same cell, the height is recalculated perfectly. So I guess I do not have any faulty constraints because, after I scroll and correct all cell heights manually, no constraint breaking warning are shown afterwards.

Edit

The below given is the screenshot of image(got messed up when cropped, but can see the issue from the profile image.). The first cell height is calculated correctly. But the rest are faulty. enter image description here


Solution

  • I have added the following and everything worked fine.

    (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath {
        return UITableViewAutomaticDimension;
    }