2012-04-22 124 views
2

在访问电池信息之前,我将BatteryMonitoringEnabled设置为True。MonoTouch电池电量始终为-1

该文档指出,只有在监视未启用时才应返回-1。

但是,我总是得到-1作为BatteryLevel属性的值,未知值为BatteryState,尽管我启用了监视。

UIDevice.CurrentDevice.BatteryMonitoringEnabled=true; 

Console.WriteLine (UIDevice.CurrentDevice.BatteryLevel.ToString()); 

结果-1

Console.WriteLine (UIDevice.CurrentDevice.BatteryState.ToString()); 

结果 “未知”

任何事情,我在这里失踪?

回答

2

这对我有用。你可以在iOS模拟器中运行这个吗?如果是这样,你所观察到的将是正常的结果。

如果你不能这样工作,请填写一个错误报告@http://bugzilla.xamarin.com,并说明正在使用哪个版本的MonoTouch,设备,iOS版本。

+0

是的,我正在模拟器中尝试这个。我的印象是它应该像普通设备一样工作。现在我知道它不应该:)是否有任何在模拟器上不起作用的列表? – SharpAffair 2012-04-22 15:33:38

+0

请记住它是*模拟器*不是*模拟器* - 有利有弊:-) – poupou 2012-04-22 15:35:39