我在tableView
中有两种不同类型的单元格布局,一种是正常高度,另一种是扩展高度。它们都是在XIB中制作的。问题是扩展单元覆盖了数据。例如,当我继续展开不同的单元格时,标签会设置一些文字,这些文字将继续添加在先前的文字之上)。表格单元格覆盖数据
下面是如何加载单元格。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *cellIdentifier = @"Cell";
static NSString *expandedCellIdentifier = @"ExpandedCell";
if (!isExpanded)
{
ListCell *cell =(ListCell*) [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell==nil)
{
NSArray *nibs = [[NSBundle mainBundle]loadNibNamed:@"ListCell" owner:self options:nil];
cell = nibs[0];
}
cell.Name.text = [[bArray objectAtIndex:indexPath.row]valueForKey:@"Name"];
return cell;
}
else
{
expCell =(ExpandedCell*) [tableView dequeueReusableCellWithIdentifier:expandedCellIdentifier];
if (expCell==nil)
{
NSArray *nibs = [[NSBundle mainBundle]loadNibNamed:@"ExpandedCell" owner:self options:nil];
expCell = nibs[0];
}
UILabel *jTime = [[UILabel alloc]initWithFrame:CGRectMake(27, 6, 72, 10)];
jTime.text = [NSString stringWithFormat:@"%@",timeRequired];
[expCell.background_View addSubview:jTime];
return expCell;
}
return nil;
}
非常感谢; - ] – iSD 2014-09-03 13:28:14