我有一个自定义的 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/