我有一个位置服务应用程序,其中提供了用户的高程.但我发现CLLocationManager提供的高程精度非常不准确.当我两次测试相同的两个点时,有时高程差是四十英尺,有时是一百.有什么办法可以提高CLLocation的垂直精度,还是有不同的方法来获取用户的高程(第三方库)?我已经尝试检查CLLocationManager提供的newLocation的verticalAccuracy属性,如果它还不够,则抛出它,但即使它足够"准确",它仍然通常不准确.谢谢你的时间!
现在我正在使用:
if([newLocation verticalAccuracy] < 30) {
if(isCustomary)
altitudeLabel.text = [NSString stringWithFormat:@"%.2f feet", ([newLocation altitude] * 3.2808399)];
else
altitudeLabel.text = [NSString stringWithFormat:@"%.2f meters", [newLocation altitude]];
}
Run Code Online (Sandbox Code Playgroud)
该代码存在问题:通常,verticalAccuracy永远不会低于30,而当它完成时,它甚至还不够准确; 我测试了在我家附近行走的代码(一个故事),它说海拔高度变化到19英尺,我确信这不是真的.
我正在使用estimote信标和区域进行一些测试.
当我开始监视一个区域时阅读文档我将告诉我的代表,但是,特定区域正在被监视,didEnterRegion并且didExitRegion永远不会被触发.
我的代表开火了:
-(void)beaconManager:(ESTBeaconManager *)manager didRangeBeacons:(NSArray *)beacons inRegion:(ESTBeaconRegion *)region
Run Code Online (Sandbox Code Playgroud)
和
- (void)locationManager:(CLLocationManager *)manager didDetermineState:(CLRegionState)state forRegion:(CLRegion *)region
Run Code Online (Sandbox Code Playgroud)
我没有检查是否发生错误locationManager:didFailWithError:
目前我正在使用状态手动运行两个私有方法,这些方法与didEnter和didExit一样工作 - 在这种情况下,我也能够监视该区域,但我没有得到原因locationManager:didEnterRegion:并且locationManager:didExitRegion:永远不会被调用.
有人面临同样的行为吗?
在我的应用程序中,每当应用程序变为活动状态时我都会更新用户位置.我CLLocationManager收到或收到更新的位置后停止applicationWillResignActive:.在Info.plist有一个NSLocationWhenInUseUsageDescription适当的描述.
如果应用程序已激活,然后立即移至后台,则表示"%MyApp%正在使用您的位置"的蓝色横幅显示的时间少于一秒.这个横幅很快就会被隐藏起来applicationWillResignActive:.
我在Google地图中注意到了同样的问题,但在Apple地图中却没有.
有没有办法完全摆脱这个横幅?我还有什么办法让iOS开心吗?我不希望它吓坏我的用户,并阻止他们使用需要位置的酷功能.
<key>NSLocationAlwaysUsageDescription</key>
<array>
<string>Location is required to find out where you are</string>
</array>
<key>Privacy-Location Usage Description</key>
<string>Location is required to find out where you are.</string>
Run Code Online (Sandbox Code Playgroud)
我在info.plist中添加了这个.仍然权限弹出窗口没有显示添加的字符串,而是显示 - 即使您不使用应用程序,也允许"app"访问您的位置?
我已经构建了一个Apple Watch App,它使用CLLocation来跟踪用户位置.应用程序的想法是使用内置GPS工作,而不需要手机.
当我运行手表应用程序时,它会提示我提供必须从手机应用程序授予的各种权限.
如果我这样做,然后开始跟踪手表,我会初次调用
- (void)locationManager:(CLLocationManager*)manager didFailWithError:(NSError*)error
这很正常,我只是再次开始追踪.然后我接到一些电话
- (void)locationManager:(CLLocationManager*)manager didUpdateLocations:(NSArray*)locations
但随后它就停止接收更新.
如果我在iPhone上运行完整曲目,然后在Watch上运行曲目,则跟踪工作正常.
测试完成:
我认为这很可能是一个苹果虫,但我希望有人可以某种方式指出我可能错过的方向.
我目前正在与之合作,CLLocationManager并希望了解该设备的当前标题.到目前为止一切正常,功能已实现,现在我尝试打磨我的应用程序.
有一个角落案例,如果用户将关闭compass calibration用户设置标题,标题更新将不再发送到我的应用程序.在这种情况下,我想给用户一些反馈,他必须再次打开罗盘校准,否则我的应用程序将无法正常工作.
我发现,如果用户关闭了location services我的应用程序,我仍然会收到磁性标题.但是如果用户关闭"罗盘校准"设置,我将不再收到更新的标题.但是,如何通过CoreLocation框架确定"罗盘校准"被关闭?
" CLLocationManagerDelegate"给了我一个更新
- (void)locationManager:(CLLocationManager*)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status
Run Code Online (Sandbox Code Playgroud)
方法.但状态仅指示"位置服务"是否为我的应用程序处于活动状态.
我也试图通过这个获得一些有效的信息
- (void)locationManager:(CLLocationManager*)manager didFailWithError:(NSError*)error
Run Code Online (Sandbox Code Playgroud)
delegate 方法,没有任何成功.
CoreLocation框架中是否有东西可以告诉我是否打开/关闭"罗盘校准"标志.
我有点简化了这个问题.当我在我的应用程序中创建和添加区域并询问这些区域的状态时,我在monitoringDidFailForRegion方法中看到以下内容:
The operation couldn’t be completed. (kCLErrorDomain error 4.)
检查CLErrorDomain常量我看到错误4是kCLErrorRegionMonitoringDenied,它的描述如下:
Access to the region monitoring service was denied by the user.
Run Code Online (Sandbox Code Playgroud)
这怎么可能?这是我的设置和我检查过的内容:
didChangeAuthorizationStatus报告正确的状态:kCLAuthorizationStatusAuthorizeddidStartMonitoringForRegion.我错过了什么?为什么在明确启用位置服务时会看到此错误?
我一直在深入研究这个使用基本计时器检查位置更新的代码.然后我将它发送到服务器的lat/lng.
http://mobileoop.com/background-location-update-programming-for-ios-7 https://github.com/voyage11/Location
当插入并通过XCode连接时,它运行良好,但是当我拔下并移动设备时,操作系统似乎总是在3分钟后完全杀死后台线程.因此,如果我将计时器设置为每30秒运行一次,我将获得~6次更新,直到我将应用程序带到前台.
我已经读过最大后台执行时间是3分钟,但是我看到这个代码在1分钟后重置了后台任务,所以我不知道为什么我会看到这个.
必须有一些解决方法.我能在这做什么吗?
编辑:这帮助我:在iOS9中的CLLocationManager中的allowsBackgroundLocationUpdates
我正在尝试获取用户的位置.为此,我在info.plist中设置了以下属性:
我还在viewDidLoad方法中添加了以下代码以及下面的函数.问题是locationManager(manager, didUpdate....)函数永远不会被调用,即使我已经删除并再次安装了应用程序,我也永远不会被提示访问位置.我在iPad上测试,而不是在模拟器上测试.didFailWithError函数永远不会被调用.
self.locationManager.delegate = self
self.locationManager.desiredAccuracy = kCLLocationAccuracyBest
self.locationManager.requestWhenInUseAuthorization()
self.locationManager.startUpdatingLocation()
func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
print("UPDATING")
let locValue:CLLocationCoordinate2D = manager.location!.coordinate
let latitude = locValue.latitude
let longitude = locValue.longitude
latitudeText = "\(latitude)"
longitudeText = "\(longitude)"
if let a = latitudeText, b = longitudeText {
print(a)
print(b)
self.locationManager.stopUpdatingLocation()
if (userAlreadyExist()) {
dispatch_async(dispatch_get_main_queue(), {
//self.performSegueWithIdentifier("segueWhenLoggedIn", sender: self)
self.performSegueWithIdentifier("showCamera", sender: self)
// self.performSegueWithIdentifier("showTabBarController", sender: self)
})
}
else {
dispatch_async(dispatch_get_main_queue(), {
self.performSegueWithIdentifier("segueWhenLoggedOut", sender: self)
})
}
}
}
func …Run Code Online (Sandbox Code Playgroud) 这是我实现谷歌地图的代码,并且CLLocationManager:
class MapViewController: UIViewController {
@IBOutlet weak var MapView: GMSMapView!
var locationmanager = CLLocationManager()
override func viewDidLoad() {
super.viewDidLoad()
locationmanager.delegate = self
locationmanager.requestWhenInUseAuthorization()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
}
extension MapViewController: CLLocationManagerDelegate {
private func locationManager(manager: CLLocationManager, didChangeAuthorizationStatus status: CLAuthorizationStatus) {
print("didChangeAuthorizationStatus")
if status == .authorizedWhenInUse {
locationmanager.startUpdatingLocation()
MapView.isMyLocationEnabled = true
MapView.settings.myLocationButton = true
}
}
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
print("didUpdateLocations")
if let location = locations.first {
MapView.camera = GMSCameraPosition(target: location.coordinate, zoom: …Run Code Online (Sandbox Code Playgroud) ios ×9
swift ×2
altitude ×1
apple-watch ×1
geolocation ×1
heading ×1
ibeacon ×1
ios7 ×1
ios8 ×1
monitoring ×1
region ×1
watchos-3 ×1
xcode ×1