0

UITabBarController에 5 개의 내비게이션 컨트롤러가 있습니다. UITabBarController가에서 있는 navigationController 중 하나는 내가 있는 navigationController 서브 클래스에 넣어 하나 의 ViewController 항상 가로 다른 모든 세로 .. 코드 위UITabBarController에서 특정 뷰 컨트롤러를 가로로 표시합니다.

-(BOOL)shouldAutorotate 
{ 
    return [self.topViewController shouldAutorotate]; 
} 

-(NSUInteger)supportedInterfaceOrientations 
{ 
    return [self.topViewController supportedInterfaceOrientations]; 
} 

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation 
{ 
    return [self.topViewController preferredInterfaceOrientationForPresentation]; 
} 

있습니다.

-(BOOL)shouldAutorotate 
{ 
    return NO; 
} 

-(NSUInteger)supportedInterfaceOrientations 
{ 
    return UIInterfaceOrientationMaskAll; 
} 

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation 
{ 
    return UIInterfaceOrientationLandscapeLeft; 
} 

는 위의 코드 나는 풍경 컨트롤러에 넣어.

나는 그것이 작동의 ViewController 아니라 단지 풍경이 화면을 표시하는 것이있는 경우이 코드

-(BOOL)shouldAutorotate 
{ 
    return NO; 
} 

-(NSUInteger)supportedInterfaceOrientations 
{ 
    return UIInterfaceOrientationMaskAll; 
} 

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation 
{ 
    if ([self isKindOfClass:[LanscapeViewController class]]) 
     return UIInterfaceOrientationLandscapeLeft; 
    else 
     return UIInterfaceOrientationPortrait; 
} 

을 넣어한다는 점에서 UIViewController 하위로 자료를 가지고 ..하지만 세로 남아있는 의 ViewController 밀어 경우 .

이 문제를 해결할 수 있습니까?

미리 감사드립니다.

답변

1

세로 모드 용 ViewController 아래 코드를 작성 했습니까?

-(BOOL)shouldAutorotate 
{ 
    return NO; 
} 

-(NSUInteger)supportedInterfaceOrientations 
{ 
    return (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown); 
} 

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation 
{ 
    return UIInterfaceOrientationPortraitUpsideDown | UIInterfaceOrientationPortrait; 
} 
+0

Pls는 검사로 방향 방법을 구현하려는

#import <UIKit/UIKit.h> @interface UIViewController (Utils) +(UIViewController*) currentViewController; @end #import "UIViewController+Utils.h" @implementation UIViewController (Utils) +(UIViewController*) findBestViewController:(UIViewController*)vc { if (vc.presentedViewController) { // Return presented view controller return [UIViewController findBestViewController:vc.presentedViewController]; } else if ([vc isKindOfClass:[UISplitViewController class]]) { // Return right hand side UISplitViewController* svc = (UISplitViewController*) vc; if (svc.viewControllers.count > 0) return [UIViewController findBestViewController:svc.viewControllers.lastObject]; else return vc; } else if ([vc isKindOfClass:[UINavigationController class]]) { // Return top view UINavigationController* svc = (UINavigationController*) vc; if (svc.viewControllers.count > 0) return [UIViewController findBestViewController:svc.topViewController]; else return vc; } else if ([vc isKindOfClass:[UITabBarController class]]) { // Return visible view UITabBarController* svc = (UITabBarController*) vc; if (svc.viewControllers.count > 0) return [UIViewController findBestViewController:svc.selectedViewController]; else return vc; } else { // Unknown view controller type, return last child view controller return vc; } } +(UIViewController*) currentViewController { // Find best view controller UIViewController* viewController = [UIApplication sharedApplication].keyWindow.rootViewController; return [UIViewController findBestViewController:viewController]; } @end 

의 UIViewController 카테고리 가져 오기의 ViewController 위 Appdelegate.m 수입에서, 현재의 ViewController를 확인하기 위해 UIViewController 카테고리 만들기 내 업데이트 된 질문 .. – TamilKing

+0

@ TamilKing, 동급의 동일 클래스 내에서 왜 당신이 kindClass를 확인 했습니까? 이 if ([self isKindOfClass : [LanscapeViewController class]]) 조건은 항상 같은 LanscapeViewController 클래스에 있기 때문에 true입니다. 모든 Landscape VC에서 모든 세로 VC와 UIInterfaceOrientationLandscapeLeft에서 UIInterfaceOrientationPortraitUpsideDown을 반환하십시오. – Punita

+0

그 UIViewcontroller의 하위 클래스입니다 그래서 모든 하위 클래스 아래에있는 viewcontroller 그래서 내가 이렇게 체크 .. 그래서 oly .. @ Punita – TamilKing

0

이 기사를 확인하십시오. http://www.klecker.de/photo/index.php?option=com_content&task=view&id=148&Itemid=213 또는 Presenting Navigation Controller in Landscape mode is not working ios 6.0 입니다.

나는 탭 모음 응용 프로그램에서 그렇게했지만 탭 중 하나의 직접적인 루트 viewcontoller를 회전시키지 않았지만 하위보기 중 하나는 강제로 회전하지 않았습니다. 탭 막대의보기 컨트롤러 중 하나에서 직접 작동하는지 확실하지 않습니다.

0

는 풍경에 보여

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window 
{ 
    if ([[UIViewController currentViewController] isKindOfClass:[YourLandScapeViewController class]]) { 

     return UIInterfaceOrientationMaskLandscape; //Orientation for LandScapeViewcontroller 

    } 
    return UIInterfaceOrientationMaskPortrait; // rest All ViewController 
}