Reputation: 879
I have a NIB file with a custom UITableViewCell
inside. I don't subclass UITableViewCell
. In my tableViewController
, I load my custom UITableViewCell
and put it in my tableView
. But when the tableView
is shown, the height of my cell is the standard `UITableViewCell height. Why? In my NIB file, the height is 311.
Upvotes: 0
Views: 1413
Reputation: 27187
This method heightForRowAtIndexPath is valid only if we know the height values for each cell. Often the custom cells have different heights and can dynamically create. If you do not know the height of the cell at the time of its creation, necessary to use additional methods. For exemple: we know the content view height for each custom cell, we can call the method reloadRowsAtIndexPaths. In method heightForRowAtIndexPath we must return value from array. When we get new value for each cells we must replace value at index in our array and call method reloadRowsAtIndexPaths. After that we get new value for each cells height.
Upvotes: 1
Reputation: 1267
If the height is the same for all table cells you would better do something like this:
self.tableView.rowHeight = 125.0;
in your custom TableViewController viewDidLoad
or init
method
Upvotes: 0
Reputation: 25642
You need to implement
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
in your table view delegate.
Upvotes: 5