What is the difference between adding the subview to self and or to the content view?
Subview added to self
- (id)initWithFrame:(CGRect)frame { if ((self = [super initWithFrame:frame])) {
UIImage *img = [UIImage imageNamed:@”lol.jpg”];
UIImageView *imgView = [[UIImageView alloc] initWithImage:img];
[self addSubview:imgView];
[imgView release];
return self;
}
Subview added to contentView
- (id)initWithFrame:(CGRect)frame { if ((self = [super initWithFrame:frame])) {
UIImage *img = [UIImage imageNamed:@”lol.jpg”];
UIImageView *imgView = [[UIImageView alloc] initWithImage:img];
[self.contentView addSubview:imgView];
[imgView release];
return self;
}
According to the Apple docs:
Generally you add to a contentView when you are comfortable with your resizing and positioning of your content being handled by the autoresize settings, and subclass UITableViewCell when you need some custom behavior and such. The Apple Table View Programming Guide has a great section on customizing UITableViewCells.