2010-06-30 2 views
1

기본적으로 TabBar 앱인 앱 (첫 번째 항목) 작업 중입니다. - 로그인보기 컨트롤러 - 탭 막대 컨트롤러 (로그인 완료시) - TabBar의 첫 번째 항목이 세로에서 가로로 전환 될 때 사용되는 가로보기 컨트롤러입니다.아이폰 : 내 가로보기에서 세로보기로 전환 할 수 없습니다.

그래서 첫 번째 탭에있을 때 다른 데이터를 표시하려면 가로보기로 이동할 수 있어야합니다. , 나는 landscapeViewController은 가로 모드에 표시 할

- (void)setSubViewTabBarViewController {  
[window addSubview:[tabBarController view]]; 
} 

- (void)setSubViewGraphLandscapeViewController { 
[window addSubview:[landscapeViewController view]]; 
} 

: 나는 setSubViewLandscapeViewController과 setSubViewTabBarController을 구현 한 대리인에

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
if([self selectedIndex] == 0) 
    return YES; 

return NO; 
} 


- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration 
{ 
[super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration]; 

// Get AppDelegate 
MyAppDelegate *delegate = [[UIApplication sharedApplication] delegate]; 

if (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight) 
{ 
    // Remove TabBarView and add graph Landscape View 
    [self.view removeFromSuperview]; 
    [delegate setSubViewLandscapeViewController]; 
} 
} 

: 내 탭 표시 줄 컨트롤러에서, 나는 그 방법을 구현 한 나는 (내 landscapeViewController에서) 다음이 : 이것의 일부가 잘 작동

풍경이에

- (void)viewWillAppear:(BOOL)animated { 
[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationLandscapeRight]; 
} 
// Override to allow orientations other than the default portrait orientation. 
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
// Return YES for supported orientations 
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight); 
} 
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration { 

NSLog(@"willRotateToInterfaceOrientation"); 
} 
, 나는 세로에서 스위치를 의미 확인 (첫 번째 탭에있을 때), tabbarcontroller는 SuperView에서 제거되고 가로보기는 하위보기로 추가됩니다.

문제는 ... 세로 모드로 전환하는 방법을 알지 못합니다 (이전 컨트롤러를로드 할 때, 내 대의원의 setSubViewTabBarViewController를 사용하여 TabBar를로드하는 방법). 가로보기에서 실제로 장치를 이동할 때 willRotateToOrientation, willRotateFromOrientation ...이 표시되지 않습니다.

요컨대, 내가 가로보기에있을 때 나는 뒤로 이동하는 것을 모릅니다 tabbar보기에 ... 나는 일단이 풍경에 있으면 일종의 가로보기에 갇혀있다.

도와 주셔서 감사합니다 많이

루크 예제 폴더에 CPTestApp 아이폰의 원형 차트에서

답변

0

글쎄, 나는이 문제에 대한 해결책을 얻을 수 있었다. 사실 세로에서 가로로 이동하면서 창 하위보기에서 tabbarcontroller를 제거하고 대신에 landscapeviewcontroller를 추가합니다. 올바른 일이 아닌 것 같습니다. 대신에 landscapeViewController를 tabbarcontroller의 하위보기로 추가하고 가로에서 세로로 갈 때이를 제거합니다. 그러나 난 여전히 몇 가지 decive 회전을 행할 때 바뀌는 것처럼 보이는 가로보기의 y 위치에 문제가 있습니다 .... 감사합니다, 룩

0

봐. -(void)didRotateFromInterfaceOrientation:을 구현하고 회전 후에 그래프의 크기를 조정하여 회전을 처리합니다.

+0

안녕하세요, 사실 나는 사실 내가 아닌 것 같아요. 정말 명확 : ( 세로 모드에서 가로 모드로 이동할 때 lanscape 뷰를로드해야했습니다. finanaly는 shouldAutorotateToInterfaceOrientation 및 willRotateToInterfaceOrientation 메소드를 사용하여이를 관리했습니다. 이제 가로 모드입니다. 어떻게 해야할지 모르겠다. 가로 모드에서 세로 모드로 회전을 처리 ... UIView를 가로 방향으로 선언 했으므로이 경우 트리거되는 메서드가 있습니까? 감사합니다. – Luc

관련 문제