2016-12-19 7 views
2

세로 99 % 인 앱만 있습니다. 한 명의 viewcontroller가 가로로 배치되어 있습니다. 따라서 내 Info.plist에는 세 가지 방향, 세로 및 가로가 있습니다.iOS : 백그라운드에서 앱을 실행 한 후 상태 표시 줄과 키보드가 회전합니다.

다음을 제외하고는 모든 것이 정상적으로 작동합니다. 앱을 배경과 앞으로 다시 가져 오면 상태 표시 줄 (및 키보드가 표시되는 경우)이 기기를 회전 할 때 가로 방향으로 회전합니다. 내 견해가 정확합니다.

이 버그는 무엇입니까? 아니면 누락 되었습니까?

+0

나는 똑같은 문제가 있으며 모든 문제를 해결할 수 없다. 나는 이것에 대해 매우 좌절하고있다. 내 앱은 스토리 보드가없는 XIB 만 사용하며 내 화면과 마찬가지로 한 화면을 제외한 모든 화면에서 세로 방향을 사용합니다. –

답변

2

application:supportedInterfaceOrientationsForWindow:을 앱 대리인에 구현할 수 있습니다. 애플의 문서에서

:

이 방법은 응용 프로그램에서 지원하는 인터페이스 방향의 전체 집합을 반환합니다. 특정 뷰 컨트롤러를 회전할지 여부를 결정할 때이 메서드에 의해 반환 된 방향은 루트보기 컨트롤러 또는 맨 위에 표시되는 뷰 컨트롤러에서 지원하는 방향과 교차됩니다. 회전이 허용되기 전에 앱 및보기 컨트롤러가 동의해야합니다. 이 메소드를 구현하지 않으면 앱은 Info.plist의 UIInterfaceOrientation 키에있는 값을 기본 인터페이스 방향으로 사용합니다.

그런 다음 같은 것을 (당신 방금 한 풍경 컨트롤러가 MyLandscapeOnlyViewController 가정) 추가 할 수 있습니다

오브젝티브 C를

 
- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window 
{ 
    // Return the desired orientation for your custom-oriented ViewController 
    if ([window.rootViewController.presentedViewController isKindOfClass:[MyLandscapeOnlyViewController class]]) 
    { 
     return UIInterfaceOrientationMaskLandscape; 
    } 

    // Default orientation is portrait 
    return UIInterfaceOrientationMaskPortrait; 
} 

스위프트 3

 
func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask { 
    // Return the desired orientation for your custom-oriented ViewController 
    if (window?.rootViewController?.presentedViewController?.isKind(of: MyLandscapeOnlyViewController.self) == true) { 
     return .landscape 
    } 

    // Default orientation is portrait 
    return .portrait 
} 

검사 가장 많이 제공되는 ViewController의 뷰 계층 구조에 따라 더 어려울 수 있지만 이는 일반적인 아이디어입니다.

희망이 도움이됩니다.

+0

내 앱에 완벽하게 작동했습니다. –