Tag: 核心位置

iOS CLLocationManager在一个单独的类

我有多个视图控制器需要获取用户的位置,所以我想创build一个单独的类,ViewControllers可以调用获取用户的最新位置。 locationManager:didUpdateToLocation:fromLocation返回void。 一旦用户的经度和纬度被计算出来,我怎样才能将纬度和经度数据传回给我的ViewControllers? 我可以尝试在我的locationManaging类中写入getter和setter,但是如果我这样做,我怎么知道何时从我的ViewController类调用纬度getter和longitude getter方法? 如何让ViewController的主线程等待locationManaging类的纬度和经度值? 谢谢!

在Swift中从callback中返回对象

我想用其他逻辑将geocoder.geocdeAddressString封装在另一个方法中。 public func placemarkForSearchResult<T>(searchResult: T) -> CLPlacemark? { if let searchResult = searchResult as? String { let geocoder = CLGeocoder() geocoder.geocodeAddressString(searchResult, completionHandler: { (placemarks, error) -> Void in // Check for returned placemarks if let placemarks = placemarks where placemarks.count > 0 { return placemarks[0] as! CLPlacemark // CLPlacemark is not convertible to void error […]

位置访问 – 应用程序不要求用户访问位置的权限 – iOS 11

描述 应用程序不要求用户访问位置的权限,并获得状态未确定 完美工作,直到iOS-10 var locationManager : CLLocationManager! func getLocationDetails() { locationManager.delegate = self locationManager.desiredAccuracy = kCLLocationAccuracyBest locationManager.requestAlwaysAuthorization() locationManager.allowsBackgroundLocationUpdates = true locationManager.startUpdatingLocation() } func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus) { if status == CLAuthorizationStatus.authorizedAlways || status == CLAuthorizationStatus.authorizedWhenInUse { locationManager.startUpdatingLocation() } } func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) { } Plist截图 背景模式

后台的StartUpdateLocations,didUpdatingToLocation只调用了10-20次

testing设备:iPhone 5(iOS 7) 我有一个使用RegionMonitoring和updateLocation的应用程序。 如果input区域, didEnterRegion预期调用didEnterRegion 。 然后我打电话给startUpdatingLocation 。 但是方法didUpdateToLocation只被调用10-20次,而它应该更新的位置,直到定时器触发。 相关代码: CLLocationManager *_locationManager; NSTimer *_timer; -(void)initLocationManager { _locationManager = [[CLLocationManager alloc] init]; _locationManager.delegate = self; [_locationManager setActivityType:CLActivityTypeOther]; [_locationManager setDesiredAccuracy:kCLLocationAccuracyBestForNavigation]; [_locationManager setPausesLocationUpdatesAutomatically:NO]; [_locationManager setDistanceFilter:kCLDistanceFilterNone]; } //Did Enter Region, called as expected: – (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region { [_locationManager startUpdatingLocation]; _timer = [NSTimer scheduledTimerWithTimeInterval:300.0f target:self selector:@selector(scheduleMethod:) userInfo:nil […]

XCode / iOS模拟器:手动触发重要的位置更改

是否有办法手动告诉设备发送重要的位置更改通知,以唤醒为此通知注册的所有应用程序? 这只是为了testing,我意识到这个私人API调用将被提交到应用程序商店被拒绝。

将MKMapView集中在引脚下方的N像素点上

希望将MKMapView居中放置在给定引脚下的N像素点( 在当前MapRect中可能不可见 )。 我一直试图解决这个使用各种戏剧-(CLLocationCoordinate2D)convertPoint:(CGPoint)point toCoordinateFromView:(UIView *)view没有成功。 任何人都在这条路上( 没有双关语 )?

有没有办法检查iOS设备是否locking/解锁?

我在我的应用程序中使用了GPS位置更新。 我想检测iOS设备是否处于睡眠模式,以便closuresGPS位置更新并优化电池使用。 我已经尝试在iOS 6暂停位置更新,但它不能按需要工作。 一旦设备进入睡眠模式,我想closuresGPS位置更新。 我想检测设备中的locking/解锁事件。 有什么办法可以实现这个function吗? 到目前为止,我得到了下面给出的达尔文通知 -(void)registerForall { //Screen lock notifications CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), //center NULL, // observer displayStatusChanged, // callback CFSTR("com.apple.iokit.hid.displayStatus"), // event name NULL, // object CFNotificationSuspensionBehaviorDeliverImmediately); CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), //center NULL, // observer displayStatusChanged, // callback CFSTR("com.apple.springboard.lockstate"), // event name NULL, // object CFNotificationSuspensionBehaviorDeliverImmediately); CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), //center NULL, // observer displayStatusChanged, // callback CFSTR("com.apple.springboard.hasBlankedScreen"), // […]

在用户拒绝使用后,如何提示用户打开位置服务

我有一个明确的用户交互的应用程序,利用用户的当前位置。 如果用户拒绝访问位置服务,我仍然希望随后的使用提示用户转到设置并为我的应用重新启用位置服务。 我想要的行为是内置的地图应用程序的行为: 在设置>常规>重置>重置位置警告中重置位置警告。 启动地图应用。 点击左下angular的“当前位置”button。 地图提示“”地图“将使用您当前的位置”| “不允许”| “允许”。 select“不允许”选项。 再次点击左下angular的当前位置button。 地图提示“打开位置服务以允许”地图“确定您的位置”| “设置”| “取消”。 在我自己的应用程序中,相同的基本stream程会导致我的CLLocationManagerDelegate -locationManager:didFailWithError:方法在最后一步被调用时出现kCLErrorDenied错误,并且用户无法打开“设置”应用程序进行更正。 为了响应这个错误,我可以显示自己的警报,但是无法启动“设置”应用程序,例如操作系统可以提供的内置地图应用程序所使用的警报。 CLLocationManager类中有什么我不知道能够给我这种​​行为吗?

iOS:应用程序在安装应用程序时不会询问用户的权限。 每次都得到kCLAuthorizationStatusNotDetermined – Objective-c&Swift

我正在尝试在iOS应用程序中获取用户位置。 我首先在我的项目中包含了corelocation框架。 然后在一个button上单击我调用核心位置API如下。 当我试图在设备中安装时,核心位置永远不会请求用户权限。 当我尝试获取button单击位置时,我得到kCLAuthorizationStatusNotDetermined作为authorisationStatus。 请帮助我。 我不知道发生了什么事。 – (IBAction)fetchLessAccurateLocation:(id)sender { [self.txtLocation setText:@""]; locationManager = [[CLLocationManager alloc] init]; locationManager.delegate = self; locationManager.desiredAccuracy = kCLLocationAccuracyKilometer; locationManager.distanceFilter = 1000; if ([self shouldFetchUserLocation]) { [locationManager startUpdatingLocation]; } } 这是我的shouldFetchUserLocation方法: -(BOOL)shouldFetchUserLocation{ BOOL shouldFetchLocation= NO; if ([CLLocationManager locationServicesEnabled]) { switch ([CLLocationManager authorizationStatus]) { case kCLAuthorizationStatusAuthorized: shouldFetchLocation= YES; break; case kCLAuthorizationStatusDenied: { […]

是否有可能使用核心位置/ GPS没有任何互联网连接/禁用蜂窝networking?

我需要在没有互联网的地区(例如帆船或撒哈拉沙漠)捕捉GPS 坐标 (不需要反向地理编码,名称等),以便获取您所在地的经纬度。 核心位置是否支持这一点,并回落到全球定位系统(没有细胞三angular测量或WiFi位置映射)? 我想是的,但只是想确定。