func application(application: UIApplication, supportedInterfaceOrientationsForWindow window: UIWindow?) -> UIInterfaceOrientationMask
{
return UIInterfaceOrientationMask.Portrait.rawValue.hashValue | UIInterfaceOrientationMask.PortraitUpsideDown.rawValue.hashValue
}
在Swift 1.2中,这个代码是可行的,但现在return语句会报错:
二进制运算符'|'不能应用于两个'UIInterfaceOrientationMask'操作数
我可以使用新类型的一个返回值来使其工作,但我无法获得第二个所需的方向。
这个代码“可行”
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个或更多值吗?