我在我的UIViewController
中有一个UITableView
。第一个单元格有type1
,其他单元格有type2
。我的问题是,我的第一个单元格的内容从不显示。 这是我的代码:iOS:不显示不同类型的UITableView第一个单元格内容
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
if(indexPath.row == 0) {
return 240;
}
return 90;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
if(indexPath.row == 0) {
Type1Cell * tmpCell1 = [tableView dequeueReusableCellWithIdentifier:@"type1Cell"];
if (tmpCell1 == nil) {
tmpCell1 = [[Type1Cell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"type1Cell"];
}
//set data
return tmpCell1;
} else {
Type2Cell * tmpCell = [tableView dequeueReusableCellWithIdentifier:@"type2Cell"];
if (tmpCell == nil) {
tmpCell = [[Type2Cell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"type2Cell"];
}
//set data
return tmpCell;
}
}
第一个单元格具有相同的指定高度,但它总是空白。我没有与其他单元格的这个问题。
检查xib或原型单元格中第一个单元的标识符 – KKRocks
@KKRocks它与我在代码 –
中所做的相同,请检查您是否对contentView或其他任何错误设置了隐藏。 –