Tag: cllocationmanager

CLLocationManager startUpdatingLocation不调用locationManager:didUpdateLocations:或locationManager:didFailWithError:

我想在我的iOS项目中使用CLLocationManager框架来访问用户的位置,但是当我打电话 [locationManager startUpdatingLocation] locationManager:didUpdateLocations:或locationManager:didFailWithError:都被调用。 //myViewController.h @interface myViewController : UITableViewController <CLLocationManagerDelegate> @end //myViewController.m @implementation myViewController{ CLLocationManager *locationManager; } //edit – (void)viewDidLoad { [super viewDidLoad]; locationManager = [[CLLocationManager alloc] init]; } //finish edit -(void)getLocation { locationManager.delegate = self; locationManager.desiredAccuracy = kCLLocationAccuracyBest; [locationManager startUpdatingLocation]; } – (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error { UIAlertView *errorAlert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Failed […]

如何使用CoreLocationfind您的当前位置

我需要find我的CoreLocation当前位置,我尝试了多种方法,但到目前为止,我的CLLocationManager只返回0 ..( 0.000.00.000 )。 这是我的代码( 更新到工作 ): import : #import <CoreLocation/CoreLocation.h> 宣布 : IBOutlet CLLocationManager *locationManager; IBOutlet UILabel *latLabel; IBOutlet UILabel *longLabel; function : – (void)getLocation { //Called when needed latLabel.text = [NSString stringWithFormat:@"%f", locationManager.location.coordinate.latitude]; longLabel.text = [NSString stringWithFormat:@"%f", locationManager.location.coordinate.longitude]; } – (void)viewDidLoad { locationManager = [[CLLocationManager alloc] init]; locationManager.distanceFilter = kCLDistanceFilterNone; // whenever we […]

如何检查iOS 4.2之前的特定应用是否启用位置服务?

我如何检查用户是否允许mu应用程序的位置? 通常我会使用CLLocationManager类的authorizationStatus方法,但它只适用于iOS 4.2及更高版本。 是否有可能以某种方式实现这一点,同时仍然使用SDK 4.2,以便应用程序仍然可以运行在具有较旧版本的iOS的设备上,还是必须降级SDK? 同样的,我需要iOS 4.0之前的locationServicesEnabled方法。 感谢名单

使用CoreLocation重要位置监控和CoreBluetooth时,电池耗尽

我们已经发布了一个在后台运行的应用程序,并使用CoreBluetooth & CoreLocation自动保存您的停车位置。 在高层次上,我们的应用程序只是寻找一个CoreBluetooth断开事件,并打开GPS,直到我们得到一个定位(精度<= 10米)或3分钟的最大时间(这可能发生在停放在没有GPS覆盖的地下停车场)。 然后,我们使用重要的位置监测来自动重新启动我们的应用程序,以防系统终止我们的应用程序。 在我们的开发过程中,我们从来没有看到自己的电池耗尽问题,但是我们75%的用户表示他们看到了显着的电池消耗。 我们的支持者中有10%对此次调查做出了回应,因此很难确定细分的代表性,但是这个用户的比例很大。 http://www.findmycarsmarter.com/forum/viewtopic.php?f=4&t=30 然后,我们发布了一个更新,允许用户禁用重要的位置监控,60%的人表示通过禁用重要的位置监控漏洞消失。 http://www.findmycarsmarter.com/forum/viewtopic.php?f=4&t=42 最初,我们不能自己重复排水问题,但是我们发现,当我们安装了一个简单的应用程序,只需打开显着的位置监测,结合查找我的汽车更智能,我们间歇性地看到了stream失的重现。 在排水状态下,手机不进入hibernate状态。 即使手机已进入睡眠状态并且显示屏已closures,((设置 – >使用情况 – >自上次完整充电以来的时间))中的使用时间也会持续增加。 有些东西阻止系统进入hibernate状态。 电池在这个阶段每小时消耗大约15%。 这个排水pipe间歇性地出现,似乎在一两个小时后自行清除,随机再来。 我们还没有find一种可靠性重现stream失的方法。 我们认为这个问题是由多个客户端调用CoreLocation引起的。 我们询问了一些遇到问题的用户,以便擦除他们的电话,并只安装“查找我的智能汽车”应用程序。 只是安装了这个应用程序,排水渠没有展示。 我们有其他的报道,当我们的应用程序与谷歌纵横或Facebook等使用,当他们看到stream失发生。 或者,如果他们去杀了其他的应用程序,漏水消失。 我们已经看到通过一个电源周期的漏洞,没有启动应用程序。 这意味着它必须是防止操作系统进入hibernate状态的系统级服务。 尽pipe我们认为这个问题是由多个客户端调用CoreLocation的一些竞争条件引起的,但我们从来没有看到使用CoreLocation的应用程序重现问题。 我们甚至创build了4个或5个不同的应用程序,将同时访问CoreLocation,我们没有看到漏水发生。 然而,当我们使用CoreLocation的应用程序和使用CoreLocation + CoreBluetooth的第二个应用程序时,我们看到了问题。 有很less的应用程序使用CoreLocation + CoreBluetooth组合,所以潜在的这就是为什么更多的开发者没有遇到这个问题。 尽pipe我们无法解释CoreLocation和CoreBluetooth如何相互作用导致这个漏洞,以及CoreLocation的第二个应用程序如何进入等式。 由于漏极是间歇性的,所以只是在我们使用CoreLocation + CoreBluetooth进行testing的时候才会出现问题。 在只有这两个应用程序安装了CTM1和FMC的5.0.1 iPhone 4S上,我们可以间歇性地进入漏极状态。 有趣的是,在我们的普通设备上,擦除设备上的漏水问题似乎不太常见。 不幸的是,我们只看到了几次排水状态,没有能够可靠地重现排水,我们没有一个良好的控制状态工作。 我们已经向苹果公司提交了一个错误报告,并且发布了一个技术支持事件,但是Stackover社区也可以提供一些见解。 我们在5.0.1和5.1 Beta 3中都看到了这个问题。 CTM1 http://www.findmycarsmarter.com/files/CTM1.zip On Going into […]

iPhone模拟器上的CLLocationManager失败,kCLErrorDomain代码= 0

iPhone模拟器上的CLLocationManager应该假冒Cupertino(不是吗?),但它不会,它会失败,而kCLErrorDomain Code=0 。 LocationManager的委托收到消息didFailWithError 。 这个方法是为了logging错误而实现的,控制台输出如下内容: Error Domain=kCLErrorDomain Code=0 "The operation couldn't be completed. (kCLErrorDomain error 0.)" 当我遇到这个问题时,我正在研究一个真正的项目,但是由于我从开发中心下载了“位置”示例代码(针对iOS 4的更新版本为2010-06-22)并且问题持续存在,所以讨论我的代码毫无意义。 该应用程序是为了启用一个“添加”button,当它收到第一个位置更新,使用户可以跟踪他们的位置,但它什么都不做。 我添加了一个(微不足道)的行来执行didFailWithError来logging错误,如果有的话。 我得到上述的错误。 使用Xcode 3.2.2和目标3.1.3,运行“Locations”项目的旧版本时,我可以获得一个固定位置(Cupertino)。 有人可以帮忙吗? 谢谢。

在iOS上检查位置服务权限

我如何检查位置服务是否为我的应用程序启用? 我有2个故事板,我想检查位置服务。 如果为我的应用程序启用位置服务,我想启动地图情节串连位置。 否则,我想推出另一个故事板。 我怎样才能编程?

replaceCLLocationManager的“目的”属性

在iOS 6中,用于描述使用位置服务( @property(copy, nonatomic) NSString *purpose )的原因的CLLocationManager的purpose属性已被弃用。 苹果公司提出了什么样的替代品?

iOS 8 Map Kit Obj-C无法获取用户位置

我正在使用Obj-C不SWIFT在iOS 8中使用Map Kit。 我不能得到设备的位置,它被设置为0.00,0.00,我得到的错误: Trying to start MapKit location updates without prompting for location authorization. Must call -[CLLocationManager requestWhenInUseAuthorization] or -[CLLocationManager requestAlwaysAuthorization] first. 我已经执行:(我一次只尝试一次,没有运气) if(IS_OS_8_OR_LATER) { [self.locationManager requestWhenInUseAuthorization]; [self.locationManager requestAlwaysAuthorization]; } [self.locationManager startUpdatingLocation]; 并在info.plist NSLocationWhenInUseUsageDescription : App would like to use your location. NSLocationAlwaysUsageDescription : App would like to use your location. 我会得到提示,允许应用程序使用我的位置,但我同意没有任何更改。 位置显示为0.00,0.00。 用于显示用户位置的代码: […]

didUpdateLocations而不是didUpdateToLocation

随着iOS6的发布,苹果希望我们使用didUpdateLocations而不是doUpdateToLocation。 任何人都可以解释如何正确使用didUpdateLocations?

为什么requestWhenInUseAuthorization不提示用户访问该位置?

在我的viewDidLoad方法中 locationManager = [[CLLocationManager alloc]init]; // initializing locationManager locationManager.delegate = self; // we set the delegate of locationManager to self. locationManager.desiredAccuracy = kCLLocationAccuracyBest; [locationManager startUpdatingLocation]; if([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0) { [locationManager requestWhenInUseAuthorization]; } 和请求被调用,但用户不会提示? 为什么?