Tag: cllocationmanager

无法分配CLLocationManager

在我的UIViewController的initWithNibNameOrNil ,我打电话: locationManager = [CLLocationManager new]; 创build对象,然后在viewDidAppear我稍后调用: [locationManager startUpdatingLocation]; [locationManager startUpdatingHeading]; 但我从来没有收到位置更新; 位置pipe理员从不开始更新位置。 但是,如果我用同一行代替initWithNibNameOrNil : locationManager = [[myAppDelegate appDelegate] locationManager]; 一切工作很好,除了随机崩溃时有时 locationManager.delegate = self; 在位置pipe理器被设置为应用程序委托中的已经分配的pipe理器之后,被设置在下一行中。 这对我来说没有任何意义。 我不明白为什么一个人和另一个人不一样,更不用说为什么他们都不一致。 有人可以开导我吗? 概要: 方法1(不起作用): 在MapView.m中 : initWithNibNameOrNil : – (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if(self) { locationManager = [CLLocationManager new]; locationManager.delegate = self; locationManager.distanceFilter […]

位置经理的准确性不是很准确

我正在向其他用户发送位置信息。 我使用Parse.com作为我的后端,并使用此代码来获取位置: -(void)sendLocation{ if ([locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)]){ [locationManager requestWhenInUseAuthorization]; } [locationManager startUpdatingLocation]; } – (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { [locationManager stopUpdatingLocation]; //kill it NOW or we have duplicates if(!self.haveLocation) { self.haveLocation=YES; NSLog(@"didUpdateToLocation: %@", newLocation); self.currentLocation = newLocation; self.currentLocationGeoPoint= [PFGeoPoint geoPointWithLocation:self.currentLocation]; } 如果我从我目前的位置发送一条消息,然后打开消息来查看它,通过比较当前的位置圈与引脚下降,我可以看到他们不在相同的地方和相当的距离。 我有BOOL var haveLocation来确保它只刷新一次。 我需要更多次刷新吗? 任何关于如何使这个更准确的指针将非常感激! 谢谢 我试过下面的苹果示例LocateMe: 我现在有: – (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation […]

当应用程序被杀时如何获得准确的位置更新?

我正在开发一个基于位置的应用程序,在这个应用程序中,用户可以存储多个位置,当用户靠近存储位置时,应用程序将通过本地通知通知用户。 我用下面的代码来实现这个function: -(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { if([[UIApplication sharedApplication] backgroundRefreshStatus] == UIBackgroundRefreshStatusDenied){ [self showAlertWithTitle:@"" andMessage:@"The app doesn't work without the Background App Refresh enabled. To turn it on, go to Settings > General > Background App Refresh."]; }else if([[UIApplication sharedApplication] backgroundRefreshStatus] == UIBackgroundRefreshStatusRestricted){ [self showAlertWithTitle:@"" andMessage:@"The functions of this app are limited because the Background […]

位置服务,如何在一段时间后(30秒)更新纬度,经度?

我从位置服务获取纬度,经度,高度,准确度,速度。 我想每30秒更新一次这些信息。 为此我使用了NSTimer: [NSTimer scheduledTimerWithTimeInterval:30 target:self selector:@selector(locationUpdate:) userInfo:nil repeats:YES]; 我把它放在viewDidLoad方法中。 它第一次显示输出,但第二次,当计时器调用它时,显示这个错误: 2011-08-02 13:17:00.141 CoreLocationAssign[1120:207] This is location <__NSCFTimer: 0x4b200a0> 2011-08-02 13:17:00.142 CoreLocationAssign[1120:207] -[__NSCFTimer coordinate]: unrecognized selector sent to instance 0x4b200a0 2011-08-02 13:17:00.144 CoreLocationAssign[1120:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFTimer coordinate]: unrecognized selector sent to instance 0x4b200a0' *** Call stack at first […]

如何在iOS应用程序中解决核心位置逻辑

我在我的应用中遇到core location逻辑问题。 以下代码位于rootviewcontroller 。 它应该testing,看看,如果用户已经允许的GPS /位置服务的应用程序开启或closures ,然后作出决定,并移动到两个view controllers 。 应用程序启动时应运行此testing。 此外,如果用户进入device Settings并更改Privacy > Location Services > App Name > ON/OFF并重新启动应用程序,那么它应该再次通过该过程。 这是我迄今为止的代码: #import <CoreLocation/CoreLocation.h> -(void) viewWillAppear:(BOOL)animated { CLController = [[CoreLocationController alloc] init]; CLController.delegate = self; [CLController.locMgr startUpdatingLocation]; #ifdef DEBUG NSLog(@"RootViewController"); #endif spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge]; spinner.center = self.view.center; spinner.hidesWhenStopped = YES; [self.view addSubview:spinner]; [spinner startAnimating]; […]

如果获得位置服务,如果他们不小心拒绝了位置服务,可以重新提取位置权限?

当用户被要求允许用户位置时,如果他们意外地select“否”,那么在我们的应用程序中从不显示该警报。 每次打开应用程序时,是否有任何重新提示警报的选项。在提到SO问题之后,很多人build议这不是全部可能的。唯一可以做的是,我们提醒用户在设置中启用位置服务。 但在一些SO问题中,每次根据用户的select启动CLLocationManager更新方法,我们可以重新提示alert.Is是否有可能实现这一点? 现在我的疑问是,当用户第一次不允许的时候可以重新提醒警报吗? 请分享你的想法。 谢谢。

如何以编程方式显示自定义用户位置

嘿,我是一个初学者,学习iOS应用程序开发,我想知道如何设置用户位置编程,就像我们在这里使用IDE(自定义位置): – 我设置一切和位置系统工作正常在我的模拟器(假的位置)我要做什么,如果我想做的同样的事情编程我工作我自己,发现了一个小解决scheme,但它不帮我出来就像缺less这里是我的代码: – – (IBAction)showMyLocation:(id)sender { CLLocation *currentLocation=[[CLLocation alloc]initWithLatitude:75.14254 longitude:75.14254]; _map.userLocation.coordinate=currentLocation.coordinate; _map.showsUserLocation=YES; } 这个代码的作品,但让我告诉你如何 如果我在模拟器中设置的位置没有任何事情发生时,我触发的行动。 如果我设置的位置任何给定的选项,让我们只要说苹果,它会显示苹果的位置,当我触发行动的位置,我只给了一次像一秒钟,再次显示苹果的位置。 所以任何能够帮助我的人都会得到真正的赞赏,我向所有问题似乎都不合适的人道歉。

当用户进入特定区域提供的ios时如何获得本地通知

我正在从事这样的项目,应用程序执行以下操作: 1.获取用户当前的位置。 2.当用户进入或附近我提供的特定位置获取本地通知。 我所做的是: 我已经下载了区域示例代码(苹果提供)来找出我的当前位置使用IOS corelocation框架。它工作正常。下面的代码: //根据地图视图的中心创build一个新的区域。 CLLocationCoordinate2D coord = CLLocationCoordinate2DMake(regionsMapView.centerCoordinate.latitude, regionsMapView.centerCoordinate.longitude); CLRegion *newRegion = [[CLRegion alloc] initCircularRegionWithCenter:coord radius:2.0 identifier:[NSString stringWithFormat:@"%f, %f", regionsMapView.centerCoordinate.latitude, regionsMapView.centerCoordinate.longitude]]; 现在我的问题是如何添加经纬度的特定区域来获得通知? 帮助是高度赞赏。任何人都知道任何例子或教程。

使用Geocoder更新属性来获取用户实际地址EXC_BAD_ACCESS

我相对是一个新的iOS开发人员,即时通讯处理地理编码器完成处理程序 ,我不明白如何更新地址parsing器的地址find一个variables,并做一些与它的东西。 总之, 我希望geocoder块在某些方法中完成使用信息 。 – (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { NSLog(@"didUpdateToLocation: %@", newLocation); CLLocation *currentLocation = newLocation; if (currentLocation != nil) { longitudeLabel = [NSString stringWithFormat:@"%.8f", currentLocation.coordinate.longitude]; latitudeLabel = [NSString stringWithFormat:@"%.8f", currentLocation.coordinate.latitude]; } [locationManager stopUpdatingLocation]; // Reverse Geocoding NSLog(@"Resolving the Address"); __block NSString * **annotation**; [geocoder reverseGeocodeLocation:currentLocation completionHandler:^(NSArray *placemarks, NSError *error) { […]

iOS:使用CLLocationManager获取准确的反向地理编码?

背景:我希望允许用户在需要的时间内,在几秒内获得他们的位置。 但是,这个位置大多是不准确的。 我想询问用户是否想再次尝试更准确的地址。 问题:如何编码,以保证下一个猜测总是比上次猜测更好。 我曾经尝试过: CLLocationManager *locationManager; – (CLLocationManager *)locationManager { if (locationManager != nil) { return locationManager; } locationManager = [[CLLocationManager alloc] init]; [locationManager setDesiredAccuracy:kCLLocationAccuracyBest]; [locationManager setDelegate:self]; return locationManager; } -(void)myLocationClickedWithCount: (int) count{ [[self locationManager] startUpdatingLocation]; CLLocation *location = [locationManager location]; CLGeocoder *locationGeocoded = [[CLGeocoder alloc] init]; [locationGeocoded reverseGeocodeLocation:location completionHandler:^(NSArray *placemarks, NSError *error) { […]