내 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