func application(application: UIApplication, supportedInterfaceOrientationsForWindow window: UIWindow?) -> UIInterfaceOrientationMask
{
return UIInterfaceOrientationMask.Portrait.rawValue.hashValue | UIInterfaceOrientationMask.PortraitUpsideDown.rawValue.hashValue
}
这曾经在 Swift 1.2 中有效,但返回行现在抛出此错误:
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
}
它说的错误与我在上面发布的错误相同。
您知道如何在 Swift 2.0 的 AppDelegate 中将方向正确设置为 2 个或更多值吗?
最佳答案
尝试新语法:
func application(application: UIApplication, supportedInterfaceOrientationsForWindow window: UIWindow?) -> UIInterfaceOrientationMask {
return [.Portrait, .PortraitUpsideDown]
}
关于swift - Swift 2.0 中的 supportedInterfaceOrientationsForWindow,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32634110/