基本上,该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
不为空,我想“跳过”单元格,不显示它并转到下一个。
请问有人对此有什么建议吗?
谢谢。