func application(application: UIApplication, supportedInterfaceOrientationsForWindow window: UIWindow?) -> UIInterfaceOrientationMask
{
return UIInterfaceOrientationMask.Portrait.rawValue.hashValue | UIInterfaceOrientationMask.PortraitUpsideDown.rawValue.hashValue
}
That used to work in Swift 1.2 however the return line is now throwing this error:
Binary operator '|' cannot be applied to two 'UIInterfaceOrientationMask' operands
I am able to get to work with just 1 return value with the new type but I cannot get it to pipe the second orientation I need.
This 'works'
func application(application: UIApplication, supportedInterfaceOrientationsForWindow window: UIWindow?) -> UIInterfaceOrientationMask
{
return UIInterfaceOrientationMask.Portrait
}
But what I 'think' I need is this:
func application(application: UIApplication, supportedInterfaceOrientationsForWindow window: UIWindow?) -> UIInterfaceOrientationMask
{
return UIInterfaceOrientationMask.Portrait | UIInterfaceOrientationMask.PortraitUpsideDown
}
And it says the same error as I posted above.
Do you know how to properly set the orientation to 2 or more values in the in the AppDelegate in Swift 2.0?
Try new syntax:
func application(application: UIApplication, supportedInterfaceOrientationsForWindow window: UIWindow?) -> UIInterfaceOrientationMask {
return [.Portrait, .PortraitUpsideDown]
}
来源:https://stackoverflow.com/questions/32634110/supportedinterfaceorientationsforwindow-in-swift-2-0