SimpleOrientationSensor返回Null [英] SimpleOrientationSensor returning Null

查看:102
本文介绍了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;
}

我知道,当没有可用的Sensor时,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?

推荐答案

根据

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天全站免登陆