2011-02-06 6 views
0

나는 이것을 작동 시키려고 노력하는 지난 몇 시간을 보냈다. 그래서 나는 내가하려고하는 것이 정확한지 알 필요가 없다. 그것 미쳤던 그 운전!UIViewController와 오리엔테이션은 올바른 방향으로 가고 있습니까?

내 목표는 방향 변경을 감지하는 ViewController를 사용하는 것입니다. 그것이 인물 일 때 UITableView를 사용하여 뷰를 보여줍니다. 가로로 표시하면 프로그래밍 방식으로 만들 컨텐트가있는 UIView가 표시됩니다. 내가 가진의 ViewController 내 부모에

:

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 

TableDataViewController *tableDataController = [[TableDataViewController alloc] 
      initWithNibName:@"TableDataViewController"                     
        bundle:nil]; 
self.tableDataViewController = tableDataController; 
[self.view insertSubview: tableDataController.view atIndex:0]; 
[tableDataController release]; 
} 

이 테이블보기와 함께 간다 컨트롤러를 포함하는 내 시야를로드합니다. 그런 다음 사용자는 장치와 기능을 회전합니다.

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toOrientation             
duration:(NSTimeInterval)duration 
{ 
if (toOrientation == UIInterfaceOrientationPortrait) { 
    NSLog(@"PerformAnalysisViewController: Gone to Potrait"); 
} 

if ((toOrientation == UIInterfaceOrientationLandscapeLeft) || 
    (toOrientation == UIInterfaceOrientationLandscapeRight)) { 
    NSLog(@"PerformAnalysisViewController: Gone to Landscape"); 

      // Load new view here 
      CGRect frame = [[UIScreen mainScreen] applicationFrame]; 
     UIView *horizView = [[[HorizView alloc] 
        initWithFrame:frame] autorelease]; 
     [self setView:horizView];; 
} 
} 

에 따라 트리거됩니다. 그러나 그것은 발동하지 않습니까? 컨트롤이 viewDidLoad에 삽입 한 Subview로 전달 되었기 때문입니까? 그렇다면 어떻게 다시 얻을 수 있습니까? 오리엔테이션을 감지하고 슈퍼 뷰에서 자신을 삭제해야합니까?

만약 그게 작동했다면 위와 같이 새 뷰를 추가 할 수 있습니까? Apple 설명서를 읽으려고했지만이 작업을 수행 할 수 없습니다.

모든 도움을 주시면 감사하겠습니다.

마이크

+0

shouldAutorotateToInterfaceOrientation : interfaceOrientation을 구현 했습니까? –

답변

0

UI 회전 처리하기 위해 나는 willRotateToInterfaceOrientation 방법을 사용하고 있습니다 :

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration { 
    if(interfaceOrientation == UIInterfaceOrientationPortrait || 
     interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) { 
     self.backgroundImageView.image = [UIImage imageNamed:@"vertical.png"]; 
    } 
    else { 
     self.backgroundImageView.image = [UIImage imageNamed:@"horizontal.png"]; 
    } 

} 

가 확인하시기 바랍니다 귀하의 Info.plist 하나 개 이상의 방향을 지원하고 shouldAutorotateToInterfaceOrientation을 구현 한 것으로, : interfaceOrientation YES를 반환합니다.

+0

그것은 촉발하지 않는 것 같습니다 - info.pist를 설정하고 shouldAutorotateToInterfaceOrientation에서 yes를 반환 함에도 불구하고 : interfaceOrientation – hydev

+0

좋아, 나는 그것을 직접 풀었다. 클래스 파일을 삭제하고 다시 시작했습니다. 어떻게 든 손상 되었어야합니다. – hydev

관련 문제