Agg*_*sor 3 uiinterfaceorientation appdelegate swift swift2
func application(application: UIApplication, supportedInterfaceOrientationsForWindow window: UIWindow?) -> UIInterfaceOrientationMask
{
return UIInterfaceOrientationMask.Portrait.rawValue.hashValue | UIInterfaceOrientationMask.PortraitUpsideDown.rawValue.hashValue
}
Run Code Online (Sandbox Code Playgroud)
以前在Swift 1.2中工作但是返回行现在抛出了这个错误:
二元运算符'|' 不能应用于两个'UIInterfaceOrientationMask'操作数
我能够使用新类型只使用1个返回值,但我无法管理我需要的第二个方向.
这''有效'
func application(application: UIApplication, supportedInterfaceOrientationsForWindow window: UIWindow?) -> UIInterfaceOrientationMask
{
return UIInterfaceOrientationMask.Portrait
}
Run Code Online (Sandbox Code Playgroud)
但我认为'我需要的是这个:
func application(application: UIApplication, supportedInterfaceOrientationsForWindow window: UIWindow?) -> UIInterfaceOrientationMask
{
return UIInterfaceOrientationMask.Portrait | UIInterfaceOrientationMask.PortraitUpsideDown
}
Run Code Online (Sandbox Code Playgroud)
它说的与我上面发布的错误相同.
你知道如何在Swift 2.0的AppDelegate中将方向正确设置为2个或更多值吗?
尝试新语法:
func application(application: UIApplication, supportedInterfaceOrientationsForWindow window: UIWindow?) -> UIInterfaceOrientationMask {
return [.Portrait, .PortraitUpsideDown]
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2204 次 |
| 最近记录: |