2014-02-14 3 views
1

SWRevealViewController을 사용하여 슬라이딩 메뉴를 구현 중입니다. 내 앱이 인물 모드로 실행 중입니다. 그러나 가로보기 모드에서보기 컨트롤러를 열어 볼 수 있습니다. 이보기 컨트롤러가 열리고 있습니다 슬라이딩 메뉴의 한보기를 클릭하십시오. Stackoverflow에서 검색했습니다.하지만 컨트롤러가 모두 AppDelegate의 rootViewController로 설정되어야합니다. UINavigation 컨트롤러가 필요합니다. 하지만 내 경우에 SWrevealViewController은 윈도우의 rootviewController으로 설정됩니다. 몇 가지 단서를 제공하여 도와주세요.슬라이딩 메뉴를 사용하여 단일보기에 가로 방향을 설정하는 방법은 무엇입니까?

답변

0

이 시도 :

에 의해
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    return interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight; 
} 

,

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    return UIInterfaceOrientationIsPortrait(interfaceOrientation); 
} 
+0

감사하지만 프로젝트 탐색기> 일반 설정에서 초상화 모드를 설정했습니다. 여기에 필요한 모든 변경 사항이 있습니다. – KDRocks

+0

예, 가로 방향을 사용하려는 경우 두 세트로 설정해야합니다. –

+0

Ok. 그러나 위의 메서드를 작성한 후에는 중복 된 메서드를 제공하고 프로젝트 탐색기 설정에서 가로 모드를 설정 한 후 .all 뷰는 lanscape 또는 portait 모드로 회전하기 시작합니다. 그러나 다른 뷰를 회전시키지 않으려했습니다. – KDRocks

1

I 가로 모드로 표시됩니다보기에서 울부 짖는 코드를 사용하여 내 문제를 해결했다합니다.

- (NSUInteger)supportedInterfaceOrientations 
{ 

    return UIInterfaceOrientationMaskLandscapeLeft; 
} 


-(void)viewDidAppear:(BOOL)animated 
{ 
    if(UIDeviceOrientationIsPortrait(self.interfaceOrientation)){ 
     if ([[UIDevice currentDevice] respondsToSelector:@selector(setOrientation:)]) 
     { 
      objc_msgSend([UIDevice currentDevice], @selector(setOrientation:), UIInterfaceOrientationLandscapeLeft); 
     } 
    } 
} 


-(void)viewDidDisappear:(BOOL)animated{ 

    if(UIDeviceOrientationIsLandscape(self.interfaceOrientation)){ 
     if ([[UIDevice currentDevice] respondsToSelector:@selector(setOrientation:)]) 
     { 
      objc_msgSend([UIDevice currentDevice], @selector(setOrientation:), UIInterfaceOrientationPortrait); 
     } 
    } 
} 
+0

비공개 API를 호출하는 것처럼 보입니까? – Marc

+0

아니요, 저는 슬라이딩 메뉴처럼 슬라이딩 페이스 북을 만들기위한 SWRevealViewController 라이브러리입니다. 오픈 소스입니다 – KDRocks

+0

@MarcMosby 제가 잘못하고 있는지 알려주세요. – KDRocks

관련 문제