2013-11-02 2 views
0

NSAriction의 NSArray를 가지고 있는데,이 배열에는 UITableView에 표시하고 싶지 않은 몇 가지 값이 있습니다.이 셀을 반환하는 것을 피하는 방법을 알고 싶습니다. tableView : cellForRowAtIndexPath :UITableviewCell을 반환하지 않는 방법

나는 return nil;을 시도했지만 이로 인해 오류가 발생했습니다.

이 어떤 도움을 주시면 감사하겠습니다

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    static NSString *CellIdentifier = @"Cell"; 
    CustomInstallCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 

    if (cell == nil) { 
     cell = [[CustomInstallCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; 
    } 

    // Configure the cell... 
    cell.selectionStyle = UITableViewCellSelectionStyleGray; 
    currentInstallDictionary = [sortedItemsArray objectAtIndex:indexPath.row]; 

     NSNumber *tempDP = [currentInstallDictionary objectForKey:@"dp"]; 
     NSInteger myInteger = [tempDP integerValue]; 

     if (myInteger == 0) { 

return cell; 
} 
return nil; // gives error 
} 

처럼 내 코드는 모습입니다.

답변

2

이 방법은 셀을 반환해야합니다. nil은 반환 할 수 없습니다. 가장 좋은 방법은 테이블을로드하고 셀을 큐에서 제거 할 때 필터링 된 배열을 사용하기 전에 목록을 필터링하는 것입니다. 당신이 물어 그 말 때문에

0

jQuery과 만 셀에 대해 요구하고있다. UITableViewDataSource 프로토콜의 구현은 두 가지 방법을 구현합니다

그 방법에서 당신이 화면에 나타납니다 얼마나 많은 세포를 결정합니다. Brian Shamblen이 대답 한 것처럼 테이블보기에 해당 데이터를 표시하지 않으려면 섹션 및 행의 수를 계산할 때 해당 데이터를 무시 (필터, 삭제 등)하는 방법이 필요합니다. 그렇게하면 "추가"셀을 요청하지 않습니다.

관련 문제