gpt4 book ai didi

iphone - 覆盖自定义 UITableViewCell

转载 作者:技术小花猫 更新时间:2023-10-29 10:44:34 25 4
gpt4 key购买 nike

我有一个自定义的 UITableViewCell,我这样使用:

AppTableCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"AppTableCell" owner:self options:nil];
for(id currentObject in topLevelObjects) {
if([currentObject isKindOfClass:[AppTableCell class]]) {
cell = (AppTableCell *)currentObject;
break;
}
}
}

完美运行。但是,我想在创建单元格时对其进行一些自定义操作。通常我会覆盖类似 initWithFrame 的东西,但它没有在这里使用。我应该覆盖什么方法来自定义初始化?

最佳答案

正确的方法是为 UITableViewCell 覆盖 awakeFromNib。

- (void)awakeFromNib
{
[super awakeFromNib];
// Do something
}

参见 references了解更多详情。

关于iphone - 覆盖自定义 UITableViewCell,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8407458/

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