gpt4 book ai didi

swift - Swift 2.0 中的 supportedInterfaceOrientationsForWindow

转载 作者:行者123 更新时间:2023-12-01 07:36:50 25 4
gpt4 key购买 nike

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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com