基本的に、cellForRowAtIndexPath
関数は UITableViewCell を返す必要があります。私のコードでは、特定の値が見つかった場合に何かをチェックしてセルをスキップする動作をチェックしたいと思います。
これが私が今持っているものです:
static NSString *FirstCellIdentifier = @"First Custom Cell";
static NSString *SecondCellIdentifier = @"Second Custom Cell";
CustomObject *o = [_customObjects objectAtIndex:indexPath.row];
if ([s.name isEqualToString:@""])
{
FirstCellController *cell = [customList dequeueReusableCellWithIdentifier:FirstCellIdentifier];
if (!cell) {
NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"FirstCustomCell" owner:self options:nil];
for (id currentObject in topLevelObjects){
if ([currentObject isKindOfClass:[UITableViewCell class]]){
cell = (FirstCellController *) currentObject;
break;
}
}
}
// Here I do something with the cell's content
return cell;
}
else {
SecondCellController *cell = [customList dequeueReusableCellWithIdentifier:SecondCellIdentifier];
if (!cell) {
NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"SecondCustomCell" owner:self options:nil];
for (id currentObject in topLevelObjects){
if ([currentObject isKindOfClass:[UITableViewCell class]]){
cell = (SecondCellController *) currentObject;
break;
}
}
}
// Here i do something with the cell's content
return cell;
}
私がやりたいのは、s.name
が空でない場合、セルを表示せずに「スキップ」して次のセルに移動したいということです。
誰でもこれについてアドバイスがありますか?
ありがとう。