위임 메서드를 사용하여 UITableView를 채우고 있습니다. 어떤 조건에서는 나는 어떤 세포도 돌려주고 싶지 않습니다. 그러나 다음 대리자 함수를 반환 형식으로 UITableViewCell 정의해야합니다. 반환하는 nil이 작동하지 않습니다 (코드 예제의 스위치 사례 참조).테이블보기 채우기 - 특정 조건에서 셀을 반환하지 않는 방법
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"UITableViewCell"];
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"UITableViewCell"];
switch (indexPath.section){
case 0:
switch (indexPath.row){
case 0:
if ([eventItemObject eventDescription]){
return cell;
} else {
return nil;
}
break;
...
default:
break;
}
break;
...
default:
break;
}
return cell;
}
특정 조건에서 셀을 반환하지 않는 방법은 무엇입니까?
글쎄, 그건 의미가있다. 오, 아뇨,하지만 스위치 문제의 숫자가 더 이상 맞지 않는다는 문제가 있습니다. Noooo ... – Bernd
실제로 NSArray에서 데이터를 읽을 지 결정할 여러 섹션이있는 경우에도 여전히 사용해야합니다. – Kassem