I have a custom table cell which has a custom ui view in it. My cell height is dynamic as it depends on the data coming from the server. Once I have data, I resize the cell frame so that it will be visible in the table.
But when I resize the cell frame by modifying the height of the cell, the cell contents never resize properly. I have set the inner views resizing masks properly, but not sure when I change the cell height in the table view’s heightForRowIndexPath delegate method by modifying the cell frame, the inner views doesn’t resize.
The work around solution I found here is, once I set new frame for cell, I set the same frame for inner container view which does resizing of all subviews.
I just need to know what might be the issue in cell resize.
Thanks in Advance
Thanks,
Naveen
There is a property on all views, autoresizesSubviews, which would enable automatic resizing. That said, what it would imply for UITableView cell is that its subviews would get resized. However, the “contentView” property of a UITableViewCell is NOT a subview, its a view that is managed by the cell. While it would seem logical that frame changes to the cell would be propagated to the contentView, they are not. I just modified a tableView project of my own to verify that autoresizesSubviews was set on both the cell and the contentView, and that cell frame changes had no effect on the contentView.
In my experience the frame height has no affect on how cells are displayed, since both the backgroundView (if there) and the contentView are “managed” not subviews. You cannot even use it for heightForRowAtIndexPath: since that call back gets called before the cell is even created (and trying to get and use it within that method causes a crash in my app).