I have a parent class like this :
@interface SGBaseTableViewCell : UITableViewCell
+ (CGFloat)defaultHeight;
...
@end
The SGBaseTableViewCell is the parent class for all my custom UITablelViewCell
@implementation SGBaseTableViewCell : UITableViewCell
+ (CGFloat)defaultHeight {
static CGFloat defaultHeight = 0.0;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
SGBaseTableViewCell *cell = [[self class] newDefaultCell]; // newDefaultCell will just load the cell from a xib
defaultHeight = cell.height;
});
return defaultHeight;
}
@end
I would like that each custom cell will returns it's height. The problem of my code is that it will always return the same height for each cell ( will return the first cell's height).
Is there a solution that each cell will return it's height without overriding in the child class the defaultHeight method ?
PS : I know that i can override the defaultHieght method in each subclass to return the appropriate height, but i would like to know if i can do it juts in the base class ?
Tnaks
UITableViewCell *cell = [[self class] newDefaultCell];?+(CGFloat)heightin cell subclass.