2015-09-17 142 views
3
func application(application: UIApplication, supportedInterfaceOrientationsForWindow window: UIWindow?) -> UIInterfaceOrientationMask 
{ 
    return UIInterfaceOrientationMask.Portrait.rawValue.hashValue | UIInterfaceOrientationMask.PortraitUpsideDown.rawValue.hashValue 
} 

這用在雨燕1.2工作然而其返回行現在就拋出這個錯誤:supportedInterfaceOrientationsForWindow在雨燕2.0

Binary operator '|' cannot be applied to two 'UIInterfaceOrientationMask' operands

我能夠獲得與新型僅有1個返回值工作但我無法得到我需要的第二個方向。

這「作品」

func application(application: UIApplication, supportedInterfaceOrientationsForWindow window: UIWindow?) -> UIInterfaceOrientationMask 
{ 
    return UIInterfaceOrientationMask.Portrait 
} 

但是我想'我需要的是:

func application(application: UIApplication, supportedInterfaceOrientationsForWindow window: UIWindow?) -> UIInterfaceOrientationMask 
{ 
    return UIInterfaceOrientationMask.Portrait | UIInterfaceOrientationMask.PortraitUpsideDown 
} 

它說我上面貼了同樣的錯誤。

你知道如何正確雨燕2.0方向設置爲2個或多個值中的AppDelegate?

回答

6

嘗試新的語法:

func application(application: UIApplication, supportedInterfaceOrientationsForWindow window: UIWindow?) -> UIInterfaceOrientationMask { 
    return [.Portrait, .PortraitUpsideDown] 
} 
+1

好奇你怎麼想通了這一點! – Aggressor