정적 셀을 사용하지 마십시오. 정적 셀은 재사용되지 않습니다. 정적 셀을 사용하면 xib에서만 표를 만들 수 있습니다.
세 가지 프로토 타입 셀을 만들고 다른 재사용 식별자를 지정하고 일반 셀처럼 사용하십시오.
테이블이 섹션으로 나누어지기 때문에 올바른 셀을 반환하기 위해 indexPath의 섹션 정보 만 사용하십시오. 이 같은
뭔가 작업을해야합니다 :
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 3;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if (section == 1) {
return _objects.count;
}
return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = nil;
if (indexPath.section == 1) {
cell = [tableView dequeueReusableCellWithIdentifier:@"SecondCell"];
// configure the mid cells
NSDate *object = [_objects objectAtIndex:indexPath.row];
cell.textLabel.text = [object description];
}
if (indexPath.section == 0) {
cell = [tableView dequeueReusableCellWithIdentifier:@"FirstCell"];
// configure first cell
}
else if (indexPath.section == 2) {
cell = [tableView dequeueReusableCellWithIdentifier:@"ThirdCell"];
// configure last cell
}
return cell;
}
너무
tableFooterView
및
tableHeaderView
특성을 살펴 있습니다. 첫 번째 항목과 마지막 항목에는 셀이 필요하지 않을 수도 있습니다.
테스트 해 보니 매력적이었습니다. 프로토 타입에 여러 식별자를 사용하는 지식이 부족했습니다. – carbonr