我有以下内容,但由于范围仅限于 if 语句,cellForRowAtIndexPath
因此无法编译。cell
写这个的正确方法是什么?
int val=indexPath.row % 2;
if(val==0) {
TRCell *cell = (TRCell*)[tableView dequeueReusableCellWithIdentifier:@"myCell"];
cell.topLabel.text = @"whatever";
cell.subLabel.text = @"down below";
} else {
TROddCell *cell = (TROddCell*)[tableView dequeueReusableCellWithIdentifier:@"cell2"];
cell.subLabel.text = @"down below in sub";
}
return cell;