UITableViewCell不使用弃用方法initWithFrame:reuseIdentifier [英] UITableViewCell without using deprecated method initWithFrame:reuseIdentifier

查看:368
本文介绍了UITableViewCell不使用弃用方法initWithFrame:reuseIdentifier的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已阅读 Loren的文章为UITableViewCell绘制自己的内容。但是,他正在使用一种弃用的方法: initWithFrame:reuseIdentifier:在UITableViewCell上已弃用。

I have read Loren's article on drawing your own content for UITableViewCell. However, he is using a deprecated method: initWithFrame:reuseIdentifier: is deprecated on UITableViewCell.

如何在不使用 initWithFrame:reuseIdentifier 的情况下让他的示例工作?

How do you get his example to work without using initWithFrame:reuseIdentifier?

推荐答案

只需要用以下内容替换 initWithFrame:reuseIdentifier:

just had to replace initWithFrame:reuseIdentifier: with the following.

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        // you might want to add the UIView to [self contentView] 
        // so that in edit's the cell's content will be automatically adjusted.
        ABTableViewCellView *myUIView = [[ABTableViewCellView alloc] initWithFrame:CGRectZero];

        myUIView.opaque = YES;
        contentViewForCell = myUIView;
        [self addSubview:myUIView];
        [myUIView release];
    }

    return self;
}

此外,苹果有一个例子,因为Loren指出但他们使用 initWithStyle:reuseIdentifier:

Also, apple has an example as Loren points out but they use initWithStyle:reuseIdentifier:

http://developer.apple.com/iphone/library/samplecode/TableViewSuite/Introduction/Intro.html

这篇关于UITableViewCell不使用弃用方法initWithFrame:reuseIdentifier的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆