Tag: 核心位置

为什么self.locationManager stopUpdatingLocation不停止位置更新

问题 :看来我无法阻止Core Location发送更新到我的应用程序/跟踪。 我在做什么 :在我的viewWillAppear我调用self.locationManager并传递给一个方法来显示用户在地图上的位置( MKMapView一个实例)。 getter被覆盖以检查serive的可用性,看是否授权。 如果是这样,它allocs/inits startMonitoringSignificantLocationChanges和startMonitoringSignificantLocationChanges和returns 。 在viewDidDisappear ,我调用[self.locationManager stopUpdatingLocation] 。 但是我仍然可以看到状态栏中的位置图标。 即使当我通过双击主页button并closures应用程序来终止应用程序时,即使在延长的时间(10分钟以上)之后,图标仍然存在。 当我去设置应用程序,它告诉我,我的应用程序仍在使用位置服务(紫色图标)。 问题:我在这里错过了什么? 为什么位置更新不停止? 提前致谢。

CLLocationManager授权问题iOS 8

我正在为iOS 8的一块Swift代码工作。我试图做一些涉及位置的东西,所以我已经在我的swift视图控制器文件中实现了以下内容: let locationManger:CLLocationManager = CLLocationManager() var speedReceived:Double = 0 override func viewDidLoad() { super.viewDidLoad() locationManger.delegate = self locationManger.desiredAccuracy = kCLLocationAccuracyBest let authstate = CLLocationManager.authorizationStatus() if(authstate == CLAuthorizationStatus.NotDetermined){ println("Not Authorised") locationManger.requestWhenInUseAuthorization() } // Do any additional setup after loading the view, typically from a nib. } func locationManager(manager: CLLocationManager!, didUpdateLocations locations: [AnyObject]!){ var location:CLLocation = […]

计算总旅行距离iOS Swift

如何计算在Swift中使用CoreLocation的总距离 我还没有能够find任何资源如何在iOS 8的Swift中做到这一点, 你将如何计算自开始跟踪你的位置以来移动的总距离? 从我读到目前为止,我需要保存点的位置,然后计算当前点和最后一点之间的距离,然后将该距离添加到totalDistancevariables Objective-C对我来说是非常陌生的,所以我一直无法制定出快速的语法 这是我到目前为止所做的,不知道我是否做对了。 虽然distanceFromLocation方法返回全部0.0,所以显然有些问题 func locationManager(manager: CLLocationManager!, didUpdateLocations locations: [AnyObject]!) { var newLocation: CLLocation = locations[0] as CLLocation oldLocationArray.append(newLocation) var totalDistance = CLLocationDistance() var oldLocation = oldLocationArray.last var distanceTraveled = newLocation.distanceFromLocation(oldLocation) totalDistance += distanceTraveled println(distanceTraveled) }

核心位置不能在iOS 8中工作

我试图在iOS 8中使用显着的更改位置监视,但didUpdateLocations方法从不调用。 以下是设置位置pipe理器的代码: – (void)viewDidLoad { [super viewDidLoad]; CLLocationManager *locationManager = [[CLLocationManager alloc] init]; locationManager.delegate = self; [locationManager requestWhenInUseAuthorization]; [locationManager startMonitoringSignificantLocationChanges]; } 尽pipe在调用requestWhenInUseAuthorization ,没有任何东西会popup来要求用户授权。 我已经设置NSLocationWhenInUseUsageDescription,它仍然无法正常工作。 didChangeAuthorizationStatus和didFailWithError也永远不会被调用。 编辑:我能够得到它要求用户允许位置服务,但即使你点击允许它永远不会显示的位置。

永远在后台运行一个Swift 2.0应用程序来更新位置到服务器

我写了下面的代码,它有一个每分钟调用一次callback函数的计时器。 当应用程序进入后台,我已经启动了另一个计时器,调用相同的callback方法,但后台计时器只能工作三分钟。 我明白,苹果允许后台任务只有三分钟。 我的应用程序更像是一个跟踪应用程序,即使应用程序在后台,也能跟踪用户的位置,所以我需要实现此function。 我了解到beginBackgroundTaskWithExpirationHandler是要使用的,但我不知道我的实现是否正确。 注意:我在plist toApp注册了位置更新所需的后台模式。 任何工作代码或链接非常感谢。 override func viewDidLoad() { super.viewDidLoad() timeInMinutes = 1 * 60 self.locationManager.requestAlwaysAuthorization() self.locationManager.requestWhenInUseAuthorization() if CLLocationManager.locationServicesEnabled() { locationManager.delegate = self locationManager.desiredAccuracy = kCLLocationAccuracyNearestTenMeters locationManager.startUpdatingLocation() } var timer = NSTimer.scheduledTimerWithTimeInterval( timeInMinutes, target: self, selector: "updateLocation", userInfo: nil, repeats: true) } func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation]){ let locValue:CLLocationCoordinate2D = manager.location!.coordinate […]

CLLocationManager响应

我有一个应用程序围绕着设备的GPS和来自它的信息。 位置数据准确和最新是非常重要的。 我知道设备受到GPS和GPS的限制,但是我想知道是否有什么可以调整/改善iPhone GPS的性能,特别是在速度方面。 由于位置更新滞后于设备实时位置约3-5秒,所以位置pipe理器报告的速度也落后于实时值。 就我而言,这太长了。 我明白,可能没有什么我可以做的,但有没有人在提高iPhone GPS的响应能力方面取得任何成功? 每一点点都有所作为 编辑1: 正如苹果推荐的,我的位置pipe理器是在单例类中。 在SingletonDataController.m里面: static CLLocationManager* locationManager; locationManager = [CLLocationManager new]; locationManager.distanceFilter = kCLDistanceFilterNone; locationManager.headingFilter = kCLHeadingFilterNone; if(([[UIDevice currentDevice] batteryState] == UIDeviceBatteryStateCharging) || ([[UIDevice currentDevice] batteryState] == UIDeviceBatteryStateFull)) { locationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation; } else { locationManager.desiredAccuracy = kCLLocationAccuracyBest; } [sharedSingleton setLocationManager:locationManager]; [locationManager release]; 在MapView.m中(实际使用位置pipe理器的地方): – (id)initWithNibName:(NSString*)nibNameOrNil bundle:(NSBundle*)nibBundleOrNil […]

如果我的应用程序处于终止状态,iOS区域监视是否会在我的应用程序上调用didEnterRegion?

如果用户在应用程序被终止之前input了一个被成功监控的区域,iOS区域监控是否会在后台启动我的应用程序? 我知道重要的变化API将会这样做,并会在启动时通过包含UIApplicationLaunchOptionsLocationKey键让我知道。 如果区域监控也会将我的应用程序从终止状态唤醒,那么启动过程是什么样子? 有一个我应该寻找的特殊的钥匙?

iOS GPS追踪应用程序,一直运行

我试图做一个应用程序来跟踪用户的GPS,这个应用程序是一种汽车GPS跟踪器,一直获取驱动程序的位置,并将其发送到服务器。 我曾尝试将“位置更新”添加到“背景模式”,但应用程序在进入后台10分钟后会自动挂起。 有没有办法让这个应用程序一直运行,并获得GPS位置? 谢谢。

deferredLocationUpdatesAvailable在iOS 10中返回NO

我正在尝试使用一些CoreLocationfunction,并遇到延迟位置更新的问题。 由于某些原因,当应用程序更新为iOS 10 deferredLocationUpdatesAvailable返回NO始终。 我正在testingiPhone 6s,所以我知道该设备是能够使用GPSfunction。 我试着用这个来debugging: [CLLocationManager deferredLocationUpdatesAvailable] 我不知道这是否是iOS 10的问题,或者如果我有东西设置不正确。 在这个方法中: – (void)locationManager:(CLLocationManager *)manager didFinishDeferredUpdatesWithError:(NSError *)error { self.deferringUpdates = NO; NSLog(@"DEFERRING Error: [%@]", error); if (error) { [[LocationManagerClient alertWithMessage:error.localizedDescription andTitle:error.domain] show]; } } 我结束了logging这个错误: DEFERRING Error: [Error Domain=kCLErrorDomain Code=11 "(null)"] 有没有人遇到这个问题与iOS 10或有任何想法是怎么回事? 编辑:这是我如何设置距离filter – (void)configureForApplicationWillResignActive { [_locationManager setAllowsBackgroundLocationUpdates:YES]; [_locationManager setPausesLocationUpdatesAutomatically:NO]; [_locationManager setDesiredAccuracy:kCLLocationAccuracyBest]; [_locationManager setDistanceFilter:kCLDistanceFilterNone]; […]

CLLocation的horizo​​ntalAccuracy和VerticalAccuracy是指什么?

最近我一直在研究一个基于位置的应用程序,并注意到CLLocation的一些奇怪的值。 我经常得到一个1414米的水平精度和-1的垂直精度。 任何线索是什么表示? 据我所知,这些点通常是非常准确的。 verticalAccuracy和horizo​​ntalAccuracy有什么区别?