Iphone 自定义UITableViewCell的覆盖
我有一个自定义的Iphone 自定义UITableViewCell的覆盖,iphone,ios,Iphone,Ios,我有一个自定义的UITableViewCell,我这样使用它: AppTableCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"AppTableCell" owner:self options:nil]; fo
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
的内容,但这里不使用它。我应该重写什么方法来自定义初始化?未从nib归档的对象将发送-initWithCoder:
消息。这就是您的覆盖点。正确的方法是覆盖UITableViewCell的awakeFromNib
- (void)awakeFromNib
{
[super awakeFromNib];
// Do something
}
有关更多详细信息,请参阅。如果对象使用插座或操作,则由于其未连接而无法工作