2014-12-26 4 views
0

특정 조건에 대해 cellForRowAtIndexPath에있는 셀 내의 view의 x 위치 프레임을 변경하려고합니다. 다음 코드를 사용했습니다. 그러나 뷰의 x position 프레임은 변경되지 않습니다.cellForRowAtIndexPath에서 프레임이 변경되지 않습니다.

- (void)viewDidLoad { 
    [super viewDidLoad]; 
UINib *nib = [UINib nibWithNibName:@"GoalDetailsCustomCardCell" bundle:nil]; 

     [goalDetailsTableView registerNib:nib forCellReuseIdentifier:@"CardCell"]; 
} 
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
    { 

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

     if(cell == nil) 
     { 
      cell = [goalDetailsTableView dequeueReusableCellWithIdentifier:@"CardCell"]; 
     } 

    NSLog(@"%f", cell.cardDetails.frame.origin.x); 
       [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); 
       }]; 
       NSLog(@"%f", cell.cardDetails.frame.origin.x); 

    return cell; 
    } 

예상대로 셀의보기가 이동하지만 음수가 아닌보기. 여전히 cardCheckReminder 뷰가 아닌 cardDetails 뷰를 보여줍니다.

참고 : NSLog는보기 프레임을 x 위치 변경으로 표시하지만보기는 -322.0 위치로 이동하지 않습니다.

+0

autolayout을 사용하고 있습니까? 'cellForRowAtIndexPath'에 nib를 등록하지 마십시오. 'viewDidLoad'에 등록하십시오. –

+0

cardDetails보기에서 xposition이 -322.0이므로 어떻게 작동하지 않는지 결정 했습니까? 화면의 너비가 화면의 너비보다 큰 경우 –

+0

@ ChintaN-Maddy-Ramani : 내 질문을 업데이트했습니다. pls보세요. 제 질문을 이해하고 올바른 길을 가고 있다고 생각합니다. –

답변

-1

cellForRowAtIndexPath의 프레임을 변경하지 마십시오 사용자 지정있는 UITableViewCell의 layoutSubviews 한 번 이상 호출 할 수 있습니다, willDisplayingCell 방법 때문에 과정을 렌더링 아이폰 OS 레이아웃의

+0

그것도 작동하지 않습니다. –

+0

당신이 Nib 파일 자체의 좌표를 조정하지 말고 사용자 정의 NIb를 사용하고 있습니다. – Geet

+0

실제로 특정 조건 만 프레임을 변경하고 싶습니다. –

1

에 변경하려고합니다. 귀하의 경우 GoalDetailsTableViewCell 클래스의 layoutSubviews 메서드에서 항목 프레임을 변경할 수 있습니다.

@implementation GoalDetailsTableViewCell 

-(void)layoutSubviews 
{ 
    [super layoutSubviews]; 
    [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); 
       }]; 
    NSLog(@"%f", cell.cardDetails.frame.origin.x); 
} 
@end 
관련 문제