Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/39.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 自定义UITableViewCell的覆盖_Iphone_Ios - Fatal编程技术网

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
}

有关更多详细信息,请参阅。

如果对象使用插座或操作,则由于其未连接而无法工作