2013-10-14 2 views
0

두 개의 테이블이있는보기가 있습니다. 이야기 게시판에는 가로와 세로 각각 두 가지보기가 있습니다. 내가보기로 이동해야하는 경우, 코드는 방향을 감지하고 적절한보기를 제공합니다 (와 방향 변경에 그렇게오리엔테이션 중 iOS 크기 조정 UITableView

나는이 내 방식에 다음 코드 :.

-(void)viewDidAppear:(BOOL)animated{ 
    UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation; 
    if(orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight){ 
    if(tableHeight2 > 324){ 
     tableHeight2 =325; 
    } 
    table1.frame = CGRectMake(table1.frame.origin.x, table1.frame.origin.y, table1.frame.size.width, tableHeight1); 
    table2.frame = CGRectMake(table2.frame.origin.x, table1.frame.origin.y + 20 + tableHeight1, table2.frame.size.width, tableHeight2); 
}else { 
    if(tableHeight2 > 500){ 
     tableHeight2 = 500; 
    } 
    table1.frame = CGRectMake(table1.frame.origin.x, table1.frame.origin.y, table1.frame.size.width, tableHeight1); 
    table2.frame = CGRectMake(table2.frame.origin.x, table1.frame.origin.y + 50 + tableHeight1, table2.frame.size.width, tableHeight2); 
} 

}

버튼을 눌러보기로 이동하면 훌륭하게 작동합니다. 셀 높이를 모두 합산하여 첫 번째 표를 적절한 높이로 만든 다음 두 번째 표를 첫 번째 표 아래로 50 픽셀 이동합니다. 두 번째 테이블이 보이는 화면 영역을 벗어나지 않도록하십시오.

,210

방향 변경, 나는 다음과 같은 코드가 실행되는 경우 :

-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)orientation duration:(NSTimeInterval)duration { 

    InitViewController *ini; 
    ini = [self.storyboard instantiateViewControllerWithIdentifier:@"Init"]; 
    ini.location = MenuName; 
    [self presentViewController:ini animated:NO completion:nil]; 
} 

는 barbuttonitem를 누르면 않습니다 같은 일해야 다음 ini.location에에 StoryboardID를 전송하는 동안 InitViewController에 변화를 변하기 쉬운. 탐색 버튼의 코드는 willAnimateRotationToInterfaceOrientation의 코드와 거의 동일합니다. 그런 다음 InitViewController가 방향을 결정하고 앱을 올바른 스토리 보드 UIView로 보냅니다.

오른쪽보기로 보내면 표 너비에 따라 알 수 있습니다. 그것은 무엇입니까 않습니다 첫 번째 (맨) 테이블, table1 높이를 변경합니다. 첫 번째 테이블은 스토리 보드에 주어진 크기를 유지합니다.

내가 더 좋은 사진을 찍으려면 게시해야한다고 생각하는 코드 영역이 있다면 알려 주시면 기꺼이 알려 드리겠습니다. 어떤 도움, 통찰력, 또는 단지 시행 착오의 제안조차도 인정 될 것입니다.

* 참고 : 영향을 미치지 않으려면 willAnimateRotationToInterfaceOrientation을 ViewDidLayoutSubviews로 변경하려고했습니다.

답변

0

글쎄, 아주 작은 변화가 수정 된 것처럼 보입니다. 탐색 버튼의 코드가보기 변경을 위해 "애니메이션"아래에 YES를 가지고 있고 willAnimateRotationToInterfaceOrientation이 "애니메이션 됨 : 아니오"로 나타났습니다. 나는 그것을 "예"로 바꾸었다. 확실하지 않음 이유는 아직입니다. 메서드가 뷰를 표시하거나로드 순서에 영향을주는 방식에 영향을 미칠 수 있지만 그럴 수 있습니다.