Reputation: 101
I inherited a custom UITableViewCell
in a project that I'm working on and now have to resize an image view
and a few labels
within the cell. However, in order to make the larger subviews
fit I would like to resize the UITableViewCell
. So in the storyboard
I changed the Row Height field, however no matter how large I make this number the cell
's size still doesn't change and the rest of my views
feel crammed in there.
Upvotes: 1
Views: 478
Reputation: 4536
First make sure that your view controller is delegate for your table view, then implement the following two delegate methods:
- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
For best performance, if height for different rows differs, cache the heights in some array.
The estimate method is not required, but helps the tableview position quicker.
Upvotes: 3
Reputation: 416
Go in the StoryBoard
and click on your custome cell
and then in the size inspector
, check custom and set row height = whatever you want.
Upvotes: 1