2014-08-28 2 views
0

일부 정보를 표시하는 배지가있는 사용자 지정 셀이 있습니다. 일부 셀에만 배지 이미지와 텍스트를 설정하고 싶습니다 (웹 서비스 응답에서 가져 오는 일부 플래그에 따라 다름). 그러나 셀을 재사용하면 배지와 텍스트가 중복됩니다. 어떻게 해결 될 수 있습니다.셀 서브 뷰 UITableView에서 중복되는 문제

배지와 텍스트는 사용자 정의 셀의 일부이며 코드를 통해 하위보기로 추가되지 않습니다.

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
    { 
     // Cell configurations 
     [self setBadgeText:indexPath :deals]; 
     return cell; 
    } 
- (void) setBadgeText:(NSIndexPath *)indexPath withObject:(VBDeals *)deals 
    { 
    [self.tableView beginUpdates]; 
    YourTableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:@"cellIdentifier" forIndexPath:indexPath];] 
    if ([deals.dealType intValue] == PUNCHCARDDEAL) 
     { 
     if ([deals.punchStatus intValue] == UNIV_INDEX_ONE && ![VBUtility isNullValue:deals.punchSpecialMessage]) 
      [cell.lblBadgeLabel setText:deals.punchSpecialMessage]; 
     else 
      [cell.lblBadgeLabel setText:[self getBadgeTextForPCD:deals]]; 
     } 
    [self.tableView endUpdates]; 
    } 
+0

당신이 당신의 cellForRowAtIndexPath 코드를 게시 할 수 :

- (void) setBadgeText:(VBMerchantDealCell *)cell withObject:(VBDeals *)deals{ if ([deals.dealType intValue] == PUNCHCARDDEAL) { if ([deals.punchStatus intValue] == UNIV_INDEX_ONE && ![VBUtility isNullValue:deals.punchSpecialMessage]) { [cell.lblBadgeLabel setText:deals.punchSpecialMessage]; }else { [cell.lblBadgeLabel setText:[self getBadgeTextForPCD:deals]]; } return; } } 
Veeru

답변

0

다음과 같은 시도? 세포를 제대로 재사용하지 않는 것 같습니다.
+0

나는이 방법을 시도했다. 더 이상 보이지 않을 때 세포를 만들지 않습니다. 이 올바른 방법입니다. 이 문제를 만듭니다 - (무효)있는 tableView : (jQuery과 *)있는 tableView didEndDisplayingCell : (있는 UITableViewCell *) 세포 forRowAtIndexPath : (NSIndexPath *) indexPath { 경우 ([tableView.indexPathsForVisibleRows indexOfObject : indexPath] == NSNotFound) { VBMerchantDealCell * cell = (VBMerchantDealCell *) [tableView cellForRowAtIndexPath : indexPath]; cell = nil; } } –

+0

별도의 방법을 사용하는 목적은 무엇입니까? cellForRowAtIndexPath 자체에서 시도해 보셨습니까? –

+0

테이블 뷰 셀에는 3 초마다 전환되는 토글 배지가 있습니다.이 전환으로 배지 이미지와 배지에 표시된 텍스트가 변경됩니다. 이들은 별도의 방법으로 처리됩니다. 현재 모든 세포가 동일한 UI 요소를 포함하지 않으므로 셀을 재사용 할 수 없습니다. 그래서 didEndDisplaying 메서드에서 셀을 nil로 만듭니다. 아무도 이것이 성능 문제를 일으킬 것이라고 말할 수 있습니까? –

관련 문제