Hur*_*rkS 1 iphone switch-statement ios
我想知道是否可能在ta开关声明案例中有一个(||)"或"或(&&)"和"运算符.
这就是我的想法.
switch (orientation) {
case UIDeviceOrientationPortrait:
{
case (UIDeviceOrientationLandscapeLeft || UIDeviceOrientationLandscapeRight):
}
break;
//...
Run Code Online (Sandbox Code Playgroud)
如果有人可以帮助我,我会非常感激:)
Jus*_*Sid 11
&&是不可能的,但你可以实现类似于||的东西 通过多个案例不间断:
switch (orientation)
{
case UIDeviceOrientationPortrait:
// ...
break;
case UIDeviceOrientationLandscapeLeft:
case UIDeviceOrientationLandscapeRight:
// ...
break;
}
Run Code Online (Sandbox Code Playgroud)
您当然也可以orientation在案例块内部工作(即进一步评估)