2013-03-27 1 views
4

3 개의 버튼이있는 사용자 정의 tableviewcell을 사용하고 있습니다.InterfaceOrientation의 customCell 내부에서 UIButtons 위치를 변경하십시오.

내가 내 사용자 지정 셀에서 layoutSubviews 방법 내부 버튼의 프레임을 설정

-(void)layoutSubviews 
{ 
   [super layoutSubviews]; 
   CGRect frame; 
   if (UIDeviceOrientationIsLandscape([UIDevice currentDevice].orientation)) 
   { 
       frame = CGRectMake(310, 7, 55, 35); 
       _prod.frame = frame; 
        
       frame = CGRectMake(365, 7, 55, 35); 
       _leva.frame = frame; 
        
       frame = CGRectMake(220, 4, 65, 65); 
       _imageButton.frame = frame; 
   } 
   else{ 
       frame = CGRectMake(150, 7, 55, 35); 
       _prod.frame = frame; 
        
       frame = CGRectMake(205, 7, 55, 35); 
       _leva.frame = frame; 
      
       frame = CGRectMake(120, 4, 65, 65); 
       _imageButton.frame = frame; 
   } 
} 

문제는, 때 예를 들어, 테이블 뷰, 방향을 변경 한 후, 가로로 사용자가 스크롤, 모든 버튼은 이전 세로 위치로 돌아갑니다. 그리고 heres는 내가 셀을 초기화하는 방법 :

LojaCell *cell = (LojaCell *) [tableView dequeueReusableCellWithIdentifier: @"LojaCell"]; 
if(cell == nil) cell = [[LojaCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"LojaCell"]; 

답변

0

당신이 cellForRowAtIndexPath에 같은 방향에 민감한 코드를 추가해야 할 수도 있습니다 다음의 tableview 다시로드하거나 세포를 다시 작성하는 경우가 올바른 위치에로드 할 수 있도록. 성능을 위해 오프 스크린 셀을 제거하는 dequeueReusableCells를 사용하고 있기 때문에 스크롤 할 때의 동작을 설명 할 수 있습니다.