航向精度为负值
我试图在屏幕上显示指南针,
if ([CLLocationManager headingAvailable]) {
CLController.locMgr.headingFilter = 0.1;
[CLController.locMgr startUpdatingHeading];
}
它进入方法,进入方法
- (void)locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading *)newHeading {
if (newHeading.headingAccuracy < 0){
NSLog(@"heading accuracy < 0");
return;
}
// Use the true heading if it is valid.
CLLocationDirection direction = ((newHeading.trueHeading > 0) ?
newHeading.trueHeading : newHeading.magneticHeading);
[self.delegate headingUpdate:direction];
}
早些时候它工作正常,但不知道现在发生了什么,
它显示“航向精度 < 0”..
I am trying to show compass on my screen
if ([CLLocationManager headingAvailable]) {
CLController.locMgr.headingFilter = 0.1;
[CLController.locMgr startUpdatingHeading];
}
it goes into method, and goes into method
- (void)locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading *)newHeading {
if (newHeading.headingAccuracy < 0){
NSLog(@"heading accuracy < 0");
return;
}
// Use the true heading if it is valid.
CLLocationDirection direction = ((newHeading.trueHeading > 0) ?
newHeading.trueHeading : newHeading.magneticHeading);
[self.delegate headingUpdate:direction];
}
Earlier it was working fine, but dont know what happened now,
It's showing "heading accuracy < 0"..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
负的标题精度值仅仅意味着指南针目前无法获得良好的读数。也许手机靠近强磁场,或者您需要以 8 字形挥动手机来校准指南针。这并不意味着您的代码不正确。
只需忽略标题精度 < 的标题更新即可。 0,并且仅使用您获得的其他值。这是正常行为。
A negative headingAccuracy value simply means that the compass cannot get a good reading at the moment. Perhaps the phone is near some strong magnetic field or you need to wave it in a figure 8 to calibrate the compass. It doesn't mean your code is incorrect.
Just ignore the heading updates where the headingAccuracy < 0, and only use the other values you get. This is normal behaviour.