2014-12-24 2 views
0

뷰가 tableViewCell 안에 있습니다. 특정 조건에서보기를 원점 x으로 옮기고 싶지만 다음 코드는 cellForRowAtIndexPath에서 작동하지 않습니다. cellForRowAtIndexPath이 완료되면 코드를 사용하면 정상적으로 작동합니다.cellForRowAtIndexPath에서 셀 내부의 뷰 프레임이 변경되지 않습니다.

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
UINib *nib = [UINib nibWithNibName:@"GoalDetailsCustomCardCell" bundle:nil]; 

[goalDetailsTableView registerNib:nib forCellReuseIdentifier:@"CardCell"]; 
GoalDetailsTableViewCell *cell = [goalDetailsTableView dequeueReusableCellWithIdentifier:@"CardCell"]; 

if(cell == nil) 
{ 
    cell = [goalDetailsTableView dequeueReusableCellWithIdentifier:@"CardCell"]; 
} 
if([self.swipedRowArray containsObject:indexPath]) 
     { 
      [UIView animateWithDuration: 0.5 animations:^{ 
       cell.cardDetails.frame = CGRectOffset(cell.cardDetails.frame, -322.0, 0.0); 
       //  CGRectOffset(cell.cardView.frame, -320.0, 0.0); 
       cell.actionCardReminder.frame = CGRectOffset(cell.actionCardReminder.frame, -322.0, 0.0); 
      }]; 
} 
} 

누구든지 도와주세요 .. 미리 감사드립니다.

+0

다음과 같이 시도하십시오. GoalDetailsTableViewCell * cell = [goalDetailsTableView dequeueReusableCellWithIdentifier : @ "CardCel % d", indexPath.row]; –

+0

너무 작동하지 않습니다. –

답변

1

사용 tableView:willDisplayCell:forRowAtIndexPath: 방법이 애니메이션 블록 :

-(void)tableView:(UITableView *)tableView willDisplayCell:(GoalDetailsTableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath { 

if([self.swipedRowArray containsObject:indexPath]) 
     { 
      [UIView animateWithDuration: 0.5 animations:^{ 
       cell.cardDetails.frame = CGRectOffset(cell.cardDetails.frame, -322.0, 0.0); 
       //  CGRectOffset(cell.cardView.frame, -320.0, 0.0); 
       cell.actionCardReminder.frame = CGRectOffset(cell.actionCardReminder.frame, -322.0, 0.0); 
      }]; 
    } 
} 

나는 당신 여부를 작동 여부를 잘 모르겠지만, 나는 단지이 방법 셀 애니메이션을 추가했습니다.

희망이 도움이됩니다.

+0

'cardItem'속성이 'UITableViewCell'유형의 객체에 없습니다. –

+0

맞춤형 셀을 사용하는 것처럼 유형 변환이 필요합니다. 내 대답이 업데이트되었습니다. – Mrunal

+0

여전히 동일한 오류가 표시됩니다. –

관련 문제