I created a new custom TableViewCell by subclassing UITableViewCell. I created a table view with UIImage view using a nib and I hooked it with view's outlets. Then while populating the table from my TableView delegate, I used the subclass for return table view cells.
New content from the nib is getting loaded. But the new size of custom table view cell (i resized the table view cell to a new large size) is not getting loaded in the table view.
Am I missing some call during the rendering? Please help
@interface AccountOption : UITableViewCell
{
IBOutlet UIImageView* optionIcon;
}
@property (nonatomic, retain) IBOutlet UIImageView* optionIcon;
@end
In delegate,
NSArray* topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"AccountOption" owner:nil options:nil];
for (id currentCell in topLevelObjects) {
if ([currentCell isKindOfClass:[AccountOption class]]) {
cell = currentCell;
}
}
cell.optionIcon.image = [(NSDictionary*)[accountOptions objectAtIndex:indexPath.row] objectForKey:@"icon"];
return cell;
You need to set the table view's row height either in interface builder, in code in your view controller, or in the table view delegate method tableView:heightForRowAtIndexPath:
Size of a cell is defined by its UITableView. The table has a property and a delegate method which define cell (row) height. Cell width is always equal to the width of the table. You can try to resize the cell manually but it will be always overwritten by the table.
The height property is [UITableView rowHeight]
and it is preferred over setting the height by table delegate method tableView:heightForRowAtIndexPath:
. The delegate method should be used only when you need different cells to have different height.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With