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

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

问题描述

我已阅读洛伦的文章 为 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

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

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