2012-08-02 5 views
0

내가 내 jQuery과 연결 사용자 정의있는 UITableViewCell의 XIB을 때 XIB 파일과 연결되어있는 UITableViewCell, 나는이 방법으로 그것을 할 수 있습니다 : 다음 변경위치 변경은 방향 변경

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
static NSString *CellIdentifier = @"MyCell"; 

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
if (cell == nil) { 
    [[NSBundle mainBundle] loadNibNamed:@"MyCustomCell" owner:self options:nil]; 

    cell = myCell; 
    self.myCell = nil; 
} 

[self configureCell:cell atIndexPath:indexPath]; 
return cell; 
} 

장치의 방향은,이 방법 내에서되도록 정의있는 UITableViewCell 일부 요소의 위치를 ​​변경하려면 :

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration { 

if (UIInterfaceOrientationIsLandscape(toInterfaceOrientation)) { 

    CGRect myframe = CGRectMake(600, self.arrowLabel.frame.origin.y, self.arrowLabel.frame.size.width, self.arrowLabel.frame.size.height); 
     self.arrowLabel.frame = myframe; 
} else { 

    CGRect myframe = CGRectMake(400, self.arrowLabel.frame.origin.y, self.arrowLabel.frame.size.width, self.arrowLabel.frame.size.height); 
     self.arrowLabel.frame = myframe; 
} 
} 

내가 접속 내 arrowLabel의 frame.origin.y 및 frame.origin.y 변경 내 UITableViewCell xib하지만 마지막 위치의 위치 만 변경 테이블 뷰의 행, 다른 행에있는 다른 레이블이 동일한 위치에 남아 있으므로 내 질문에 테이블 뷰를 다시로드 할 수 있습니다 ...? 또한 시도한 [self.tableview reloadData]; ...하지만 돈을 일하면 ... 어떤 생각?

답변

0

cellForRowAtIndexPath에 프레임 변경 코드를 넣으십시오. 기본적으로이 방법 당신은 같은 있습니다

if (portrait) { 
    // use portrait frames 
} else { 
    // use landscape frames 
} 

을 다음 willRotate 방법에 당신은 [tableView reloadData]를 호출 할 수 있습니다.

편집 :

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration { 

for (UITableViewCell *cell in [tableView visibleCells]) { 

    if (portrait) { 
     CGRect myframe = CGRectMake(600, cell.arrowLabel.frame.origin.y, cell.arrowLabel.frame.size.width, cell.arrowLabel.frame.size.height); 
     cell.arrowLabel.frame = myframe; 
    } else { 
     CGRect myframe = CGRectMake(400, cell.arrowLabel.frame.origin.y, cell.arrowLabel.frame.size.width, cell.arrowLabel.frame.size.height); 
     cell.arrowLabel.frame = myframe; 
    } 
} 
} 
+0

... 난 이미 나는 또한 내가하려고 한 cellrowforindexpath 방법 ... – Piero

+0

를 호출 작동하지 않습니다 reloadData ... – Piero

+0

으로 시도라고 어떤 변화? 아니요, 'cellForRowAtIndexPath' 메소드에서 오리엔테이션에 따라 사용할 프레임을 지정합니다. 그런 다음'willRotate'에서'reloadData'를 호출 할 수 있습니다. – aforaudrey