Tag: cllocationmanager

为什么CLLocationManager总是返回true?

我正在使用[CLLocationManager locationServicesEnabled]函数来获取是否启用位置服务的状态。 我保持viewDidLoad方法中的代码。 if(![CLLocationManager locationServicesEnabled]) { NSLog(@"No"); } else { NSLog(@"Yes"); } 当我第一次运行这个应用程序时,它返回Yes 。 为什么? 它应该返回我No 。 当我没有select“允许”或“不允许”选项时就是这种情况。 我意味着我既不允许也不允许,但是在我viewDidLoad我已经得到了。 现在我select“不允许”,并再次加载相同的viewController 。 这个时候至less应该还给我No ,但是我还是得到了。 为什么? 与CLLocationManager混淆很多。 有任何想法吗?

Objective C,iOS 7 – CLLocationManager:didUpdateLocations只被调用一次

编辑:好吧,我只是已经注意到,这个问题是独家的iOS 7。我仍然无法解决它,但是,我认为我会尝试与下面的sugestions。 谢谢大家! ¡嗨! 我正在编程一个导航器应用程序,我需要更新用户的位置,只要有可能。 我有两个使用CLLocationpipe理器的视图控制器。 在他们两个,我已经添加了这一行: #import <CoreLocation/CoreLocation.h> 然后将其添加到接口声明中,并将其设置为.h文件中的属性,然后进行合成: @property (strong, nonatomic) CLLocationManager *locationManager; 之后,我将在viewDidLoad中启动de locationManager,如下所示: if(self){ locationManager = [[CLLocationManager alloc] init]; //locationManager.delegate = self; [locationManager setDelegate:self]; [locationManager setDistanceFilter:kCLHeadingFilterNone]; [locationManager setDesiredAccuracy:kCLLocationAccuracyBestForNavigation]; [locationManager startUpdatingLocation]; } 这里是我的委托方法。 对于第一个视图: #pragma mark – CLLocationManagerDelegate – (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error { NSLog(@"didFailWithError: %@", error); UIAlertView *errorAlert = [[UIAlertView alloc] […]

在自己的类中的Objective-C源码locationManager

我想从自己的类中获取locationManager,我可以从其他类调用它。 我做了什么。 创build一个iPhone应用程序,并在ViewController中添加locationManger代码。 工作。 现在我创build了一个类Lokation ,将所有的locationManager代码移动到这个新类中,并从ViewController中调用该代码。 结果:函数getLocation被调用,但是locationmanager:manager didUpdateToLocation:newLocation fromLocation:oldLocation不被调用。 产量 2013-07-03 15:44:14.124 Sandbox2 [41374:c07] Inside Lokation :: getLocation 缺less什么?如何整合? 有些东西告诉我“代表”,但我是这个主题的新手。 ViewController.h #import <UIKit/UIKit.h> #import <CoreLocation/CoreLocation.h> @interface ViewController : UIViewController <CLLocationManagerDelegate> @end ViewController.m(20130704更新为工作代码) #import "ViewController.h" #import "Lokation.h" @interface ViewController () // 20130704 added property @property (strong, nonatomic) Lokation *lokation; @end @implementation ViewController – (void)viewDidLoad { [super […]

CLLocationManager保存caching值

CLLocationManager这部分代码用于计算行进距离。 但是即使在使用timeIntervalSinceNow之后,位置caching也不会被删除。 – (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { if(newLocation != nil && oldLocation != newLocation) { tempNewLocation = newLocation; tempOldLocation = oldLocation; } NSLog(@"New Location Found"); NSLog(@"- Latitude: %f", newLocation.coordinate.latitude); NSLog(@"- Longitude: %f", newLocation.coordinate.longitude); NSLog(@"- Altitude: %f", newLocation.altitude); NSLog(@"- Course: %f", newLocation.course); NSTimeInterval locationAge = -[newLocation.timestamp timeIntervalSinceNow]; NSLog(@"The location age %f",locationAge); if (locationAge […]

'CLLocationManager'没有可见的@interface声明select器'requestAlwaysAuthorization'

我们正在制作一个应用程序来兼容iOS 8,但同时,我们的一些开发人员还没有Xcode 6,所以他们在尝试调用时出现这个错误 [self.locationManager requestAlwaysAuthorization]; 即使是在一个if里面 if(floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_7_1) { [self.locationManager requestAlwaysAuthorization]; } 我们如何解决这个在Xcode 5上编译?

如何使我的ios应用程序出现在设置中的位置服务

我写了一个CLLocationManager ios应用程序。 但是,我看不到我的应用程序出现在我的iPhone设置中的定位服务中。 我需要在Xcode的ios项目中设置plist的特定值吗? 提前致谢!

为什么iOS 11更新后,后台模式下的位置更新速度较慢?

在位置更新期间,iOS被用来在后台唤醒我的应用程序。 在更新到iOS 11之后,“唤醒”过程需要更长的时间(用户覆盖一英里或2英里的距离之后)。 我还没有看到与此相关的位置pipe理器文档的任何新的更改。 任何其他人遇到同样的问题?

从用户位置查找最接近的经度和纬度

我有一个经度和纬度丰富的arrays。 我有两个双重variables与我的用户位置。 我想testing我的用户位置与我的arrays之间的距离,以查看哪个位置是最接近的。 我该怎么做呢? 这将获得2个位置之间的距离,但拼图理解我将如何对arrays的位置进行testing。 CLLocation *startLocation = [[CLLocation alloc] initWithLatitude:userlatitude longitude:userlongitude]; CLLocation *endLocation = [[CLLocation alloc] initWithLatitude:annotation.coordinate.latitude longitude:annotation.coordinate.longitude]; CLLocationDistance distance = [startLocation distanceFromLocation:endLocation];

iBeacon蓝牙didEnterRegion和didExitRegion方法永远不会被触发

非常奇怪的是,在didEnterRegion didExitRegion之后, didEnterRegion和didExitRegion永远不会被触发。 另外, didDetermineState可以按期望触发。 在现阶段,我只根据苹果示例代码演示Airlocated评估iBeacon技术。 因此,我只实现了两个方法,包括文件APLAppDelegate.m中的didEnterRegion和didExitRegion ,如下所示: – (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region { NSLog(@"Entered region: %@", region); [self sendLocalNotificationForBeaconRegion:(CLBeaconRegion *)region]; } – (void)locationManager:(CLLocationManager *)manager didExitRegion:(CLRegion *)region { NSLog(@"Exited region: %@", region); } 波纹pipe的步骤已经尝试过,但没有效果。 使用iOS7.1重置iPhone5 / iPhone4s 将背景模式和* .plistconfiguration为如下forms: 在项目信息或info.plist – >自定义IOS目标属性 – >。 添加“所需的背景模式”。 在这添加两个项目 – >“应用程序共享数据使用CoreBluetooth”。“应用程序注册的位置更新” 在项目能力 – >有背景模式 。 检查“Loaction更新” 。 检查“用作蓝牙LE配件”。 […]

CLLocationManager startMonitoringForRegion:设备重启后不重新启动应用程序

好的,所以我现在有一个应用程序,我使用CLLocationManager startMonitoringForRegion方法注册一个地理栅栏来监视。 这个应用程序在前台和后台时正常工作。 我也有适当的plist值设置: UIBackgroundModes :{location} UIRequiredDeviceCapabilities: {location-services} 什么都行不通 设备重新启动后,应用程序不会重新启动。 如果在进入后台之前设置了startMonitoringSignificantLocationChanges ,我可以强制执行此操作。 但这种方法使用更多的电池寿命,我不需要所有的时间,只要我打破地理围栏。 地区的文档说: In iOS, the regions you register with the location manager persist between launches of your application. If a region crossing occurs while your iOS app is not running, the system automatically wakes it up (or relaunches it) in the background so […]