Reputation: 32091
I've created a custom cell class using these instructions: http://www.bdunagan.com/2009/06/28/custom-uitableviewcell-from-a-xib-in-interface-builder/
Everything worked great, except I have one small issue. The height of the background image of the cell is 100px. However when I launch the app, it seems to be using default height of cells, which is around 50px or so. How can I fix this? My custom cell is loaded from an XIB, and in that XIB the cell has the desired height of 100px, but it's still using default height in simulator.
Upvotes: 0
Views: 134
Reputation: 1356
Change the row height of UITableView (not your custom cell) in your interface builder or programmatically.
I don't think you have to override heightForRowAtIndexPath. Also based on http://iphoneincubator.com/blog/windows-views/the-right-way-to-set-the-height-of-tableviewcells, you will get better performance without using heightForRowAtIndexPath.
Upvotes: 1
Reputation: 13694
In your Table View Controller you need to override the heightForRowAtIndexPath and set the height to 100.0px as so:
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 100.0f;
}
Upvotes: 1
Reputation: 7936
You still need to return the new height from heightForRowAtIndexPath.
Upvotes: 1
Reputation: 30846
Set the rowHeight
property on your instance of UITableView
. It accepts a CGFloat
.
If all of your cells will be of the same height it is best to use the rowHeight property instead of the tableView:heightForRowAtIndexPath:
delegate method. Using the delegate method incurs a cost on scrolling performance.
self.tableView.rowHeight = 100.0f;
Upvotes: 1