Nick Triantafillou
Nick Triantafillou

Reputation: 585

Change height of UITableViewCell without heightForRowAtIndexPath

I had some UITableViewCells I was adding to a UITableView, but the structure of the page has changed, so now I need to add them to a UIView instead. (I'm sure this is a big red flag right here, they're going into one of several UIView's which appear when "tabs" are pressed).

Is it possible to modify their heights? I've been able to add them to my UIView by adding them as subviews in static positions (which is fine), but they're being cut off as they're no longer using heightForRowAtIndexPath to determine their height.

Here's my example, I've outlined the UIViews with red borders, so the UIView each cell is in is the correct size:

enter image description here

Is this possible or should I just add another UITableView inside the UIView I've moved them to?

Upvotes: 0

Views: 263

Answers (1)

T. Benjamin Larsen
T. Benjamin Larsen

Reputation: 6393

If moving the cells into another view is the path you want to go down, this is certainly possible. (Cells are after all a UIView as good as any). I would try you simply resizing the tableViewCell's contentView, or even turn the cell's clipsToBounds = NO; to avoid the clipping you're experiencing when resizing the cells.

...

That being said though, are you sure you really want to abandon tableViews? What exactly is forcing you to change the design, and why would the tableView pattern no longer be appropriate? Perhaps sharing some more details about the project and what you are trying to achieve would lead to a better solution...

Upvotes: 1

Related Questions