2014-07-08 3 views
0

내 uitableviewcells 위에 '줄 구분 기호'를 수동으로 추가 할 수 있습니다. (기본 제공되지 않는 iOS에서는이를 위해 자르지 않습니다.) 그래서 UIViews의 배열이라고 _separatorLines, 내가 셀을 선택하면 그러나, 나는 다른 모든 세포를 원하는초기화 후 UITableViewCell의 ContentView를 변경할 수없는 이유

UIView *v   = [_separatorLines objectAtIndex:indexPath.row]; 
    [cell.contentView addSubview:v]; 

으로 cellForRowAtIndexPath ''내에있는 contentView '는 uitableviewcells 각 인덱스에서 하나의 UIView를 추가를 만들었습니다 라인 구분 기호가 빨간색으로 바뀝니다. 'didSelectRowAtIndexPath'에서 나는이 :

{ 
for(unsigned int i = 0; i < _rowsInSection-1; i ++) 
{ 
    //make all other rows have a red content view 
    if(i != indexPath.row) 
    { 
      NSIndexPath *I = [NSIndexPath indexPathForRow:i inSection:1]; 
      UITableViewCell *cell = [self tableView:tableView cellForRowAtIndexPath:I]; 

      UIView *separatingLineView = [_separatorLines objectAtIndex:I.row+1]; 
      separatingLineView.backgroundColor = [UIColor redColor]; 
      [cell.contentView bringSubviewToFront:separatingLineView]; 
      [separatingLineView setNeedsDisplay]; 

      [cell setNeedsDisplay]; 
      [cell.contentView setNeedsDisplay]; 
     } 
    } 

    [self setNeedsDisplay]; 

대신 내가 변화 uitableviewcells의있는 contentView를 볼 수 없습니다.

답변

0

내게 문제가 있다고 생각합니다. NSIndexPath * I = [NSIndexPath indexPathForRow : i inSection : 1];

UITableView는 섹션 '0'에서 시작합니다 (행이 '0'에서 시작하는 것처럼).

는 또한 내 jQuery과 대리자이기 때문에, 나는

[self tableView:tableView cellForRowAtIndexPath:I]; 

사용을 중단하고 그것으로 아무 상관이 있다면

[self cellForRowAtIndexPath:I]; 

확실하지 그것을 대체

관련 문제