【发布时间】:2012-08-18 21:04:03
【问题描述】:
我的自定义 UITableViewCell 遇到了一个非常奇怪的问题。我在 Interface Builder 中有一个标识符为“ThreadCell”的单元格,并带有一些自定义标签。这些标签被标记,因此我可以访问它们。
在我的代码中,我正在执行以下操作:
static NSString *CellIdentifier = @"ThreadCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if(cell == nil){
cell = [[UITableViewCell alloc] initWithStyle: UITableViewCellStyleDefault reuseIdentifier: @"ThreadCell"];
}
Person *person = [self.people objectAtIndex: indexPath.row];
UILabel *nameLabel = (UILabel *)[cell viewWithTag: 0];
nameLabel.text = person.nickname;
return cell;
这似乎工作正常,但有一个例外。 TableView 是这样绘制的:
这显然不是我的自定义单元格。但奇怪的是,当我点击一个单元格时,我得到了这个:
这个是我的自定义单元格,在默认单元格后面绘制。 什么?!我不确定这是怎么发生的,因为我从来没有在任何地方设置文本视图的标题,所以我不确定第一个 John Smith 来自哪里。
有人有什么想法吗?
【问题讨论】:
标签: objective-c ios interface-builder