SimpleOrientationSensor 返回 Null [英] SimpleOrientationSensor returning Null

查看:36
本文介绍了SimpleOrientationSensor 返回 Null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 SimpleOrientationSensor 在我的应用程序中获取屏幕方向信息.我正在 Windows Simulator 中测试此应用程序,但我总是将传感器对象的值设为 null.

I'm using SimpleOrientationSensor to get the screen orientation information in my application. I'm testing this application in Windows Simulator but I always get the sensor object's value as null.

这就是我正在做的:

SimpleOrientationSensor sensor;

sensor = SimpleOrientationSensor.GetDefault();
if (sensor != null)
{
     sensor.OrientationChanged += sensor_OrientationChanged;
}

我知道 SimpleOrientationSensor.GetDefault() 将在没有可用传感器时返回 null.我应该调整模拟器以获取传感器信息吗?或者它甚至处理这些变化?

I understand that SimpleOrientationSensor.GetDefault() will return null when there is no Sensor available. Should I tweak the Simulator to get the sensor information? Or does it even handle these changes?

推荐答案

根据 这篇文章 模拟器不支持SimpleOrientationSensor 类.

According to this article the simulator doesn't support the SimpleOrientationSensor class.

模拟器不支持方向传感器的仿真,只能触发显示方向变化.

The Simulator doesn’t support the emulation of Orientation Sensor, and is only able to trigger a display orientation change.

这篇关于SimpleOrientationSensor 返回 Null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆