How to enable only landscape mode in a UWP app?

前端 未结 3 1611
醉酒成梦
醉酒成梦 2020-12-11 19:17

I have already specified in the manifest as Landscape and LandscapeFlipped, I know this is just a preference and on top of this I\'ve added the below code in the App.xaml.cs

3条回答
  •  囚心锁ツ
    2020-12-11 20:11

    You used the right API to force the orientation in UWP app, but you can refer to the official DisplayOrientations enumeration, in the remarks part:

    Applications typically use this property to translate the reading of an accelerometer or to translate the physical button events in accordance with the current screen rotation.

    It means, these work but only if the device has an accelerometer, on laptop even simulator, they have no effect.

    Also is there any alternative way I could test this in a simulator instead of an actual tablet/device?

    No, simulator is not suitable, you can test this on Mobile or Mobile emulator.

提交回复
热议问题