0

이미 선택된 셀을 다시 선택 (손가락을 올리지 않고 만진 경우) 할 때 UITableViewCell의 textLabel 속성과 관련된 문제가 있습니다.UITableViewCell textLabel 높이가 동일한 셀을 선택/강조 표시 한 후 다시 설정됩니다.

동적 높이 (셀 포함)와 textLabel의 배경이 일관되게 동일한 높이 (50.0f-ish) 인 textLabel 바로 아래의 배경에 사용자 정의 contentView가 추가되었습니다.

나는 beginUpdates 및 endUpdates 메서드를 사용하여 선택 영역과 프레임 변경을 애니메이션으로 적용하여 업데이트가 발생한 직후에 텍스트 레이블의 가운데 맞춤을 방지합니다. 이를 배경과 거의 동일하게 유지합니다. 다른 셀을 선택할 때 아무런 문제가 없으며 textLabel이 있어야하는 위치에 머물러 있습니다.

주요 문제는 사용자가 선택한 셀에서 다시 손가락을 건 드리면 셀의 높이에 따라 텍스트 레이블이 뒤 바뀌는 것입니다.

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 
     DetailView *detailView = // Create detail view 

     // Add UIImageView from content to cell -------------------- 
     UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; 

     // Change textLabel colors, fontSize, and shadow properties 
     // Create CustomContentView *ccView = nil; 


     // ------ 
     // Remove/Hide any existing CustomContentViews 
     // --- Code here 
     // ------- 

     switch (hasImageInCustomView) { 
     case YES: 
      image = _imageInCustomView; 
      image = NO; 

      if (selectedIndexPath.row != indexPath.row) { 
       [tableView beginUpdates]; 
       [tableView endUpdates]; 
      } 

      CGRect frame = cell.textLabel.frame; 
        frame.size.height = 50.0f; 
        cell.textLabel.frame = frame; 


      return; 
     break; 
     default: 
      image = [detailView getImage]; 
     break; 
     } 

     // ---- 
     // Calculate height for image and add that to heightForExpandedRow property 
     // -- Code here... 
     // ---- 

     [tableView beginUpdates]; 
     [tableView endUpdates]; 

     // Add subview with UIImageView 
     customContentView = [[CustomContentView alloc] initWithFrame:(CGRect){0, 0, kWidth, dynamicExpandedRow}]; 
     contentView.clipsToBounds = YES; 
     [cell.contentView addSubview:customContentView]; 
     [cell.contentView sendSubviewToBack:customContentView]; 
     [customContentView setContentImage:image]; 

     CGRect frame = cell.textLabel.frame; 
     frame.size.height = 50.0f; 
     cell.textLabel.frame = frame; 

} 

나는 내가 didHighlightRowAtIndexPath는 생각하지 않는다 아이폰 OS 3.0을 사용하고 있습니다 : 작동 및 beginUpdates이/EndUpdates 사이가 호출 된 후 textLabel라는 프레임을 다시 어떤 대리인 방법이 있는지 궁금 해서요.

I 프레임의 변화를 기록했고 그렇게처럼 제공 :

beginUpdates이/EndUpdates 사이가 호출 및 수동 프레임 한 후 beginUpdates/EndUpdates 사이가

<UILabel: 0x4e55500; frame = (10 0; 250 199); text = 'Some Text Goes Here...'; clipsToBounds = YES; opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x4e55570>> 

호출되기 전에

변경

<UILabel: 0x4e55500; frame = (10 0; 250 50); text = 'Some Text Goes Here...'; clipsToBounds = YES; opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x4e55570>> 

높이가 199 그 두 가지 방법이 호출되고 이후에는 50이 호출됩니다. 그러나 텍스트 프레임은 강제 프레임 변경에 관계없이 선택한 셀을 다시 선택할 때마다 셀에서 세로로 다시 들어가게됩니다.

누구든지 도움을받을 수 있다면 크게 감사하겠습니다.

링크는 예를 그리는 ->http://i50.tinypic.com/2r6o5k5.jpg

+0

관련 문제를 기반으로 UITableViewCell을 서브 클래 싱하고 layoutSubviews를 사용하여 작업하고 있습니다. – Bill

+0

슬프게도, UITableViewCell을 서브 클래 싱하고 layoutSubviews로 작업하지 못했습니다.사용자가 선택한 셀을 다시 선택하고 textLabel의 크기가 세로로 가운데에있는 동안 셀의 새 확장 된 높이에 맞게 재설정되면 문제가 지속됩니다. – Bill

답변

0

셀이 당신이 UILabel의 높이를 변경하기 전에 바로 다음 조건을 추가를 선택하면 당신은 UILabel의 높이를 변화하고 있습니다.

처음에 selectedIndexRow는 -1이됩니다.

당신이 너무 ... 당신은 많은 코드를 변경할 필요가 없습니다 상태 이상 추가 selectedIndex의 확인됨에 따라
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 
//Check if we are selecting the same cell 
     if(selectedIndexRow != indexPath.row){ 
      if(selectedIndexRow != -1){ 

     //deselect the previous cell 
     } 

      selectedIndexRow = indexPath.row; 

     //preform your action 

     } 
    } 

..

+0

글쎄, 글꼴 크기 및 색 이외의 시각적 인 변경없이 높이에서 셀을 확장 할 때 상단에 고정 textLabel 계속 노력하고있어. – Bill

+0

@Bill 스냅 샷을 추가 할 수 있습니까? 그래야 도움이 될 것입니다 – Anand

+0

자, 잠깐만 요. – Bill

0

는 시도이 하나 : 당신이이

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
return 50; 
} 

사용자 정의가 아닌 기본 레이블을 사용하기 때문에 셀 높이가 증가합니다.

+0

나는 이미 이것을 가지고 있지만, 통찰력에 감사드립니다! – Bill

+0

ok :) 환영합니다 .. – Abha