我已阅读 Loren's article关于为 UITableViewCell 绘制您自己的内容。但是,他使用的是一种已弃用的方法:initWithFrame:reuseIdentifier:
is deprecated on UITableViewCell。
如何在不使用 initWithFrame:reuseIdentifier
的情况下让他的示例工作?
最佳答案
只需将 initWithFrame:reuseIdentifier:
替换为以下内容即可。
- (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:
http://developer.apple.com/iphone/library/samplecode/TableViewSuite/Introduction/Intro.html
关于ios - UITableViewCell 不使用不推荐使用的方法 initWithFrame :reuseIdentifier,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2815121/