You will always have a landscape, because this is your default value (from your if statement). If you go through the debugger with a breakpoint, you will see that the orientation specified is unknown.
In fact, your code is fine, but this is a simulator limitation. If you take the same code using device orientation rather than interface orientation, you will get actual values ββif you use it on a physical device, which can be controlled using the if statement.
source share