0
我在我的应用程序中使用了两种不同的UITableViewCell
。理想情况下,我想使用它们像这样:更改自定义UITableViewCell
if (self.data.count > 0) {
static NSString * reuseIdentifier = @"programmaticCell";
articleCell * cell = [self.tableView dequeueReusableCellWithIdentifier:reuseIdentifier];
if (!cell) {
cell = [[articleCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:reuseIdentifier];
}
return cell;
} else {
static NSString * reuseIdentifier = @"programmaticCell";
emptyCell * cell = [self.tableView dequeueReusableCellWithIdentifier:reuseIdentifier];
if (!cell) {
cell = [[emptyCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:reuseIdentifier];
}
cell.header.text = @"No data";
[cell.button setTitle:@"Button" forState:UIControlStateNormal];
return cell;
}
然而,当我使用上面的代码,它崩溃。当数据从服务器下载时,首先会显示1 emptyCell
。加载后,UITableView
被刷新,应用程序崩溃,因为它试图再次使用emptyCell
。我该如何解决这个问题?
提供有关崩溃的详细信息。 – rmaddy
我高度怀疑你可以对两种不同的UITableViewCell使用相同的可重复使用的标识符......你在两种情况下使用了不同的标识符。 – luk2302