How to create your own TableViewCell with initWithStyle after 3.0

I am trying to create my own TableViewCell with initWithStyle since it says that initWithFrame is deprecated after 3.0. Everything used to be fine with initWithFrame.

Are there any tutorials or code examples for this? Thank you

+4
source share
1 answer

I subclassed a UITableViewCell, then overrides the initWithStyle method.

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) { self.selectionStyle = UITableViewCellSelectionStyleNone; // Initialization code msgText = [[UILabel alloc] init]; [self.contentView addSubview:msgText]; } return self; } 

msgText is a class UILabel property, and I set the text property of the label elsewhere. You can add any kind of self.contentView you like. I also set the frame for each of the subzones when I add content such as text and / or images.

+7
source

All Articles