Tag: cllocationmanager

ios7中的重大更改事件 – 后台服务调用

我在我的应用程序中使用重要的位置服务。 如果我的应用程序被系统杀死或被用户强行closures,使用重大位置更改服务事件,我正在iOS 6中将位置数据发送到我的服务器。在iOS6中,我的应用程序也在强制closures后将数据发送到服务器。 但在iOS 7我没有得到这个重大的位置变化事件。

CLLocationManager didUpdateLocations不被调用

我正在用Swift学习iOS 8应用程序的开发过程。 我遵循了一个关于Treehouse的教程,它引导您在Swift和iOS 8中构build天气应用程序。 作为应用程序的改进,作者/导师build议使用CLLocationManager来获取设备的位置,以便将其馈入天气API,而不是硬编码的经度和纬度值。 所以在网上阅读各种教程,我已经走了,试图实现这个build议的改进。 我已经将代码负责获取AppDelegate.swift文件中的位置坐标。 AppDelegate.swift代码 import UIKit import CoreLocation @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate, CLLocationManagerDelegate { var window: UIWindow? var locationManager: CLLocationManager! var errorOccured: Bool = false var foundLocation: Bool = false var locationStatus: NSString = "Not Started" var location: CLLocationCoordinate2D? var locationName: String? func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> […]

CLLocationManager委托方法没有被调用

我正在使用CLLocationManager类。 我有一个简单的类捕获位置的方法 +(void)captureLocation{ mLocationManager = [[CLLocationManager alloc]init]; mLocationManager.delegate = (id<CLLocationManagerDelegate>)self; mLocationManager.desiredAccuracy = kCLLocationAccuracyBest; [mLocationManager startUpdatingLocation]; } 我也有CLLocationManager的委托方法 – (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error { } – (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { } 现在我试图在我的viewDidLoad调用这个方法 – (void)viewDidLoad { [super viewDidLoad]; [myclass captureLocation]; } 该方法正在调用,但委托方法没有被调用。 我也有其他的类方法,如果我再次尝试调用方法captureLocation方法被调用,但不调用委托方法。 这是另一个类的方法 +(void)initialize{ [self captureLocation]; } 请帮我找出为什么委托方法没有被调用,因为我是这个领域的新手。 提前致谢。

函数“didUpdateToLocation”被调用而没有改变

我这样初始化locationManager: if (!self.locManager) { self.locManager = [[CLLocationManager alloc] init]; self.locManager.delegate = self; [locManager startMonitoringSignificantLocationChanges]; } 我的设备不动,仍然每次都调用“didUpdateToLocation”。 什么可能是一个问题? 谢谢

在iOS中实现定期位置更新,即使应用程序终止

我的应用程序需要定期更新位置(每10分钟)。 在前台和后台(应用程序未终止)应用程序正常工作。 但是,当应用程序被用户终止时,问题就开始发生。 我尝试使用本教程http://mobileoop.com/getting-location-updates-for-ios-7-and-8-when-the-app-is-killedterminatedsuspended 。 它只在用户的位置由于startMonitoringSignificantLocationChanges而改变时才起作用 。 但是即使用户没有改变位置,我也需要终止状态的位置。 此外,我已经尝试了大部分的stackoverflow问题,但他们大多数满意startMonitoringSignificantLocationChanges 。 但就我而言,仅仅满足应用需求是不够的。

如何获得当前在xamarin中的GPS坐标

我想获取用户的当前经度和纬度ios在Xamarin。 我看了其他职位,据我了解。 就像是: CLLocationManager lm = new CLLocationManager(); … (Acurray) … (Other Specs) lm.StartUpdatingLocation(); lm.Location.Coordinate.Latitude.ToString(); lm.Location.Coordinate.Longitude.ToString(); 但是,当我在模拟器中运行它不会做任何事情。 它并不要求我打开我的位置服务或更新我的标签的经纬度。 另外,我如何使它检查位置服务打开,如果他们不是。 如何让用户做到这一点。 (如在某些应用程序上popup,要求您打开您的GPS)

尽pipe基于位置的应用程序使用快速应用程序切换器杀死,但状态栏中显示灰色GPS箭头

我正在为iOS 5编写一个基于位置的应用程序。应用程序正在使用CLLocationManager来接收位置更新。 当应用程序启动时,我正在创buildLocationManager,调用[self.locationManager startUpdatingLocation]; 灰色的位置箭头出现在状态栏中。 当应用程序进入后台我打电话 [self.locationManager stopUpdatingLocation]; [self.locationManager startMonitoringSignificantLocationChanges]; 因为我只想在应用程序处于后台时收到重要的位置更改。 灰色的位置箭头仍然显示。 我在我的应用程序中也有一个退出button [self.locationManager stopUpdatingLocation]; exit(0); 当用户按下“退出”button时,应用程序结束,灰色位置button从状态栏中消失。 一切都很好,直到现在。 当用户使用快速应用程序切换器完成应用程序时,会出现问题,因为之后灰色位置箭头仍显示在状态栏中,尽pipe应用程序未运行。 当用户从他的iPhone中删除应用程序时,灰色位置箭头首先消失。 所以问题是: 当用户使用快速应用程序切换器完成应用程序并且灰色箭头仍显示在状态栏中,这是否意味着,位置更新仍然执行或这是否意味着应用程序在过去24小时内使用位置服务? 我想答案是第一个,位置更新仍然执行! 应用程序需要在后台执行,所以当应用程序进入后台时,无法停止LocationManager。 applicationWillTerminate:当用户使用快速应用程序切换器杀死应用程序时从未被调用。 有什么办法可以收到一个事件,当应用程序被终止使用快速应用程序切换器或终止的操作系统? 我已经看到一些其他的应用程序,当应用程序被快速应用程序切换器杀死时,状态栏中的灰色箭头消失。 这些应用程序如何实现?

iOS 8 gps未启用

我解决了一个问题,即GPS服务在iOS 7上完美工作,但在iOS 8上,我从来没有获得权限请求和方法: – (void) locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations 永远不会被调用。 我的代码在这里: #import "Locator.h" @implementation Locator – (instancetype) init { if (self = [super init]) { // Start up the location manager self.locationManager = [[CLLocationManager alloc] init]; self.locationManager.delegate = self; self.locationManager.desiredAccuracy = kCLLocationAccuracyBest; self.locationManager.distanceFilter = 3; // New property for iOS6 if ([self.locationManager respondsToSelector:@selector(activityType)]) { self.locationManager.activityType […]

didUpdateLocation方法从未调用

我正在iphone sdk4.0上做一个应用程序。在那个更新的位置方法从来没有调用。 我已经给我的代码below.Please help.Thanks提前。 -(id)init { [super init]; obj=[[UIApplication sharedApplication]delegate]; locationManager = [[CLLocationManager alloc] init]; locationManager.delegate = self; //locationManager.distanceFilter = kCLDistanceFilterNone; // whenever we move locationManager.desiredAccuracy = kCLLocationAccuracyHundredMeters; // 100 m [locationManager startUpdatingLocation]; return self; } -(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { NSLog(@"%f",newLocation.coordinate.latitude); NSLog(@"%f",newLocation.coordinate.longitude); obj=[[UIApplication sharedApplication]delegate]; location=[[CLLocation alloc]initWithLatitude:newLocation.coordinate.latitude longitude:newLocation.coordinate.longitude]; obj.lattitude1=[NSString stringWithFormat:@"%f",newLocation.coordinate.latitude]; obj.longitude1=[NSString stringWithFormat:@"%f",newLocation.coordinate.longitude]; //location=[[CLLocation […]

我怎样才能继续更新我的位置,即使应用程序被杀死或从背景中删除ios?

我的应用程序需要不断更新位置,即使应用程序被杀死或从后台删除。 它在前台甚至后台模式下都能正常工作,但在应用程序被杀时不工作。 我试过一些代码。 func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { self.startLocationService() if ((launchOptions?[UIApplicationLaunchOptionsLocationKey]) != nil) { self.locationmanager = CLLocationManager() self.startLocationService() } print("Location Updates started") return true } func startLocationService() { self.locationmanager.requestWhenInUseAuthorization() self.locationmanager.desiredAccuracy = kCLLocationAccuracyBest self.locationmanager.allowsBackgroundLocationUpdates = true self.locationmanager.requestAlwaysAuthorization() self.locationmanager.delegate = self if UIApplication.sharedApplication().backgroundRefreshStatus == .Available { print("Background updates are available for the […]