2013-07-30 2 views
1

LoginTableViewController이라는 응용 프로그램의 초기 컨트롤러 인 UITableViewController가 있습니다.전화 방향에 따라 UITableViews를 변경하십시오.

나는 가로 모드에 대한 세로 모드 다른 하나의 UITableView을 보여주고 싶어요.

현재 가로 모드로 다른 UITableViewController (LoginTableViewController_L)을 설정했습니다. 나는 방향에 따라 UITableViews을 바꿀 수 있기를 바라고 UITableViewController을 의 프리 UITableView이라고 선언했습니다. 전화를 돌린 후 상단에 제목 표시 줄이있는 검은 색/빈 화면이 나타납니다.

더 좋은 방법이 있나요?

@property (strong, nonatomic) IBOutlet UITableView *LoginTableView; 
@property (strong, nonatomic) IBOutlet UITableView *LoginTableView_Landscape; 
+1

"더 나은 방법"에 관해서는 다른 방향에 대해 적절한 레이아웃 조정으로 동일한 테이블보기를 사용하지 않는 이유는 무엇입니까? – jstevenco

+0

테이블 뷰 데이터 소스/대리자가 연결되어 있지 않거나 자동 크기 조정과 관련된 문제가있는 것 같습니다. –

+0

가로보기에 다른 레이아웃을 사용하고 싶습니다. 나는 레이아웃 조정으로 그렇게 할 수 있다고 생각하지 않는다. –

답변

1

하나의 TableView를 사용하십시오.

당신은 완전히 다른 모습 (크기를 조정할뿐만 아니라 같은 세포)를 원하는 경우

장치의 방향을 감지하고 현재 방향에 따라 서로 다른 세포를로드합니다.

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 

    static NSString *CellIdentifier = @"Cell"; 

    UIInterfaceOrientation interfaceOrientation = [[UIApplication sharedApplication] statusBarOrientation]; 

    if (UIInterfaceOrientationIsPortrait(interfaceOrientation)) { 

     PortraitCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
     if (cell == nil) 
     { 
      cell = [[PortraitCell alloc]init]; 
     } 

    } else { 

     LandscapeCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
     if (cell == nil) 
     { 
      cell = [[LandscapeCell alloc]init]; 
     } 
    } 

    return cell; 
} 

장치 방향 변경 개념을 표시

[myTableView reloadData]; 

* PsudoCode 호출 할 때.

관련 문제