开发者

How to make custom TableViewCell with initWithStyle after 3.0

I am trying to have custom TableViewCell with initWithStyle, since 开发者_如何学编程it says initWithFrame is deprecated after 3.0. Everything worked fine with initWithFrame before.

Is there any tutorials or sample code available for this? Thanks.


I have subclassed UITableViewCell then override 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 UILabel property of the class and I set the text property of the label elsewhere. You can add any views to self.contentView you like. I also set the frame of each of the subviews when I add the content like text and/or images.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜