Xcode:如何显示 GPS 强度值?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10583449/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 00:19:15  来源:igfitidea点击:

Xcode: How to show GPS strength value?

iphoneiosxcodegps

提问by Luai Kalkatawi

I am trying to get the GPS strength value to show if the signal is strong or weak. Does anyone know how to get the value.

我正在尝试获取 GPS 强度值以显示信号是强还是弱。有谁知道如何获得价值。

Thanks in advance.

提前致谢。

回答by Anshuk Garg

use the properties of CLLocationlike horizontalAccuracyand verticalAccuracywhich indicate how accurate the device believes that location fix to be.

使用的属性CLLocationhorizontalAccuracyverticalAccuracy其指示设备如何准确认为,位置锁定被。

and u can use

你可以使用

 if (someLocation.horizontalAccuracy < 0)
{
    // No Signal
}
else if (someLocation.horizontalAccuracy > 163)
{
    // Poor Signal
}
else if (someLocation.horizontalAccuracy > 48)
{
    // Average Signal
}
else
{
    // Full Signal
}

taken from linkhope it helps. happy coding :)

取自链接希望它有帮助。快乐编码:)

回答by Lefteris

You could have used the excellent search function of stackoverflow and find this solution:

您可以使用 stackoverflow 出色的搜索功能并找到以下解决方案:

Finding GPS signal strength

寻找 GPS 信号强度

回答by Rok Jarc

You don't have direct access to number of visible satellites or signal strength.

您无法直接访问可见卫星的数量或信号强度。

You could however calculate fake signal strength from accuracy.

但是,您可以根据准确性计算假信号强度。

-(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
   NSLog (@"accuracy: H:%.2f, V:%.2f", newLocation.horizontalAccuracy, newLocation.verticalAccuracy);
}