supportedInterfaceOrientationsForWindow in Swift 2.0
Asked Answered
C

1

3
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?

Chancechancel answered 17/9, 2015 at 15:19 Comment(0)
V
6

Try new syntax:

func application(application: UIApplication, supportedInterfaceOrientationsForWindow window: UIWindow?) -> UIInterfaceOrientationMask {
  return [.Portrait, .PortraitUpsideDown]
}
Vanquish answered 17/9, 2015 at 15:22 Comment(1)
Curious how you figured this out!Chancechancel

© 2022 - 2024 — McMap. All rights reserved.