开发者

How to make custom TableViewCell with initWithStyle after 3.0

开发者 https://www.devze.com 2022-12-11 23:33 出处:网络
I am trying to have custom TableViewCell with initWithStyle, since 开发者_如何学编程it says initWithFrame is deprecated after 3.0. Everything worked fine with initWithFrame before.

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

精彩评论

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

关注公众号