장치 회전 제어

2473 단어 Xcode6SwiftiOS8

배경.


각 화면(ViewController)을 회전 제어하려는 경우
회전 가능한 모든 방향을 먼저 지정합니다.

UISupportedInterfaceOrientations



ViewControllershouldAutoroate, supportedInterfaceOrientations
나는 단지 과속 제어를 어떻게 하는지 알 뿐이다.
나는 그다지 총명하지 않다고 생각해서 다른 방법을 찾았다.

회전 제어 방법


다음과 같이 각 ViewController에 대해 회전을 제어할 수 있습니다.

소스 코드


AppDelegate.swift

func application(application: UIApplication, supportedInterfaceOrientationsForWindow window: UIWindow?) -> Int {
        if window?.rootViewController?.presentedViewController is ViewController2 {
            return Int(UIInterfaceOrientationMask.AllButUpsideDown.rawValue)
        } else {
            return Int(UIInterfaceOrientationMask.Portrait.rawValue)
        }
    }

그러면 U I S u p o rted Interface Orientations는 무엇입니까?


UISupportedInterfaceOrientations
이 조사에 따르면 앱을 시작할 때 취할 수 있는 방향을 지정한 것으로 보인다.

좋은 웹페이지 즐겨찾기