Sn0wfreeze
Sn0wfreeze

Reputation: 2031

UITableViewCell automatic height incorrect on iOS

We all came across a UITableView where we wanted to have different cell heights that adopt dynamically to font sizes. Now in my table view I have multiple different cells that have a different height.
I used the standard code to allow estimated heights and dynamic resizing:

self.tableView.estimatedRowHeight = 450.0
self.tableView.rowHeight = UITableViewAutomaticDimension

Now my new cell has been created using a xib file so I can check if all constraints have been set correctly. The weird thing is that when I run it on the iOS Simulator the cell height is rendered too small.

It does not matter what constraint I use even when I preset a height constraint the height of the cell will always be around the same height as the other cells, which use a correct automatic height.
When I want to debug this issue by using the View Debugger in Xcode the height of cell will be rendered correctly as I wanted it.

Here's a screenshot as an example: enter image description here

The left side shows the view debugger. The right size the iOS simulator.
The same thing happens if I use an App like Reveal.

Maybe someone had the same issue and can help me with it.

Upvotes: 1

Views: 105

Answers (1)

Marcin Nowak
Marcin Nowak

Reputation: 152

I bet your UIImageView doesn't clip image :)

just set

yourImageView.clipsToBounds = true

and it should help

Upvotes: 2

Related Questions