为了UITableViewCell绘制自己的内容,我已经阅读了
Loren’s article.但是,他正在使用不推荐使用的方法:initWithFrame:reuseIdentifier:在UITableViewCell上已被弃用.
如何让他的示例工作,而不使用initWithFrame:reuseIdentifier?
解决方法@H_301_6@
只需要使用以下命令替换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
- (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