I would want to create a custom UITableViewCell which should have a different appearance than the default implementation. For this I subclassed the UITableViewCell and want to add a label, textbox and a background image. Only the background image seems not to appear.
Maybe I’m completely on the wrong track here and maybe subclassing a UITableViewCell is a bad idea after all, is there any reason why that would be the case and is there a better way?
Anyhow this is what I tried, in the subclass’s initWithStyle I put the following:
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self == nil)
{
return nil;
}
UIImage *rowBackground;
backRowImage = [UIImage imageNamed:@"backRow.png"];
((UIImageView *)self.backgroundView).image = backRowImage;
}
What am I doing wrong here? Should I set the background image in the drawRect method as well?
According to the header file, the backgroundView defaults to nil for plain-style tables. You should try creating your own UIImageView and sticking it in there.