2 つのセクションのグループ化されたテーブルがあります。
最初のセクションは 1 つのセルのみで、XIB を持つ特定のサブクラスです。表の残りのセルには、XIB なしの基本データが表示されます。
私が抱えている問題は、最初のセルが再利用されるときです。セルのサブクラスは、明らかに XIB を使用するセルのサブクラスのままであるため、データを適用しようとすると、その場所に適切なラベルなど。
最初のセルを無視して 2 番目のタイプのセルを使い続けるか、セルのタイプを変更する必要があります。
この状況を処理する最善の方法は何ですか?また、どのようにそれを達成しますか?
私はもう試した
if (cell == nil || [cell isKindOfClass:[InspectionMasterTableViewCell class]])
しかし、これは何の効果もないようです。
私の cellForRowAtIndexPath の基本的なレイアウトはこれです
if (indexPath.section == InspectionsMasterSectionData)
{
// CREATE CELL
static NSString *CellWithIdentifier = @"InspectionMasterTableViewCell";
InspectionMasterTableViewCell *cell = (InspectionMasterTableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellWithIdentifier];
if (cell == nil)
{
NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"InspectionMasterTableViewCell" owner:nil options:nil];
cell = [topLevelObjects objectAtIndex:0];
}
return cell;
}
else
{
static NSString *CellWithIdentifier = @"FormTableViewCell";
FormTableViewCell *cell = (FormTableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellWithIdentifier];
if (cell == nil || [cell isKindOfClass:[InspectionMasterTableViewCell class]])
cell = [[FormTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellWithIdentifier];
//CELL DATA
return cell;
}