gpt4 book ai didi

ios - UITableViewCell 不使用不推荐使用的方法 initWithFrame :reuseIdentifier

转载 作者:技术小花猫 更新时间:2023-10-29 11:14:50 26 4
gpt4 key购买 nike

我已阅读 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com