草庐IT

didUpdateLocation

全部标签

ios - 'locationManager(_:didUpdateLocations:)' 的参数具有与协议(protocol) 'CLLocationManagerDelegate' 预期不同的可选性

我在我的ViewController中实现了CLLocationManagerDelegate,但我收到了以下警告Parametersof'locationManager(_:didUpdateLocations:)'havedifferentoptionalitythanexpectedbyprotocol'CLLocationManagerDelegate'Parametersof'locationManager(_:didFailWithError:)'havedifferentoptionalitythanexpectedbyprotocol'CLLocationManager

swift - 错误 : 'Delegate must respond to locationManager:didUpdateLocations:' when collecting user location

所以我想在用户点击按钮时收集用户位置,并稍后在我的应用程序中使用该位置。在我当前的实现中,当点击按钮时,应该提示用户允许共享位置,然后他们应该登录到应用程序(如果你想知道的话,通过Firebase匿名登录),并且应该打印用户位置信息到控制台。提示有效,但是在点击允许位置按钮后,我的应用程序终止duetouncaughtexception'NSInternalInconsistencyException'原因是'DelegatemustrespondtolocationManager:didUpdateLocations:'这很奇怪,因为我的代码中确实有一个didUpdateLocati

ios - didUpdateLocations 未被调用

我将我的对象设置为locationManager的委托(delegate),并调用了didChangeAuthorizationStatus方法,它执行以下操作:funclocationManager(manager:CLLocationManager!,didChangeAuthorizationStatusstatus:CLAuthorizationStatus){ifstatus==CLAuthorizationStatus.AuthorizedWhenInUse{self.locationManager.startUpdatingLocation()}}我也有这个方法,它永远不

swift - iOS 9 中的 requestLocation() 多次调用 didUpdateLocation 委托(delegate)

所以在iOS9上有了新的requestLocation()方法。我试图用它来只获取一个位置更新,但它多次点击didUpdateLocations。这不是应该只调用一次吗?我已将distanceFilter设置为1000.0,因此范围很广,有助于快速返回。有任何想法吗?即使我在委托(delegate)方法中调用stopUpdatingLocation(),我仍然会得到三次委托(delegate)。注意:当我改用StartUpdatingLocation时会发生相同的行为,我只想返回一次,因为我想获得用户的当前国家/地区,因此将位置提供给reversegeocoder提前致谢代码如下:fu

iphone - CLLocationManager 不会将位置发送到 didUpdateLocations 方法

我正在开发启用了ARC的iOS6.1iPhone应用程序,它将使用CLLocationManager来跟踪设备位置。更新我有一个DestinationViewController实现了CLLocationManagerDelegate。它创建CLLocationManager并进行设置。我已将CoreLocation框架导入到我的项目中。我尝试了很多调试,可以看到CLLocationManager已创建并且没有错误。但问题是[CLLocationManagerauthorizationStatus]是kCLAuthorizationStatusNotDetermined在[self.l

ios - 为什么 didUpdateLocations locations NSArray 中的位置永远不会超过一个?

我设置了以下方法:-(void)locationManager:(CLLocationManager*)managerdidUpdateLocations:(NSArray*)locations它工作正常并被调用,但它从未包含多个位置。我试图在手机移动时获取新旧位置之间的距离。我错过了什么吗?locations数组中永远不会有两个项目。 最佳答案 正如didUpdateLocations的文档所说,数组是.........AnarrayofCLLocationobjectscontainingthelocationdata.This

ios - 在ios中实现CLLocationManager的didUpdateLocations委托(delegate)方法

我已经在DashboardController.m中实现了-(void)localnotification。现在我想访问localnotification并在settingsController中实现didUpdateLocations委托(delegate)方法.m类。到目前为止,我的方法是:DashBoardViewController.h#import@classAppDelegate;@interfaceDashBoardViewController:UIViewController{AppDelegate*appDel;}@property(nonatomic,strong)

iphone - 位置管理器 :didUpdateLocations: always be called several times

我在View确实出现时开始更新当前位置,并在调用locationManager:didUpdateLocations:时停止更新位置。但为什么locationManager:didUpdateLocations:总是被调用多次?我错过了什么?#import"ViewController.h"@interfaceViewController(){CLLocationManager*locationManager;//locationmanagerforcurrentlocation}@end@implementationViewController-(void)viewDidLoad{[

iphone - 从未调用过 didUpdateLocation 方法

我正在iphonesdk4.0上制作一个应用程序。在其中没有调用从未调用过的更新位置方法。我在下面给出了我的代码。请帮忙。提前致谢。-(id)init{[superinit];obj=[[UIApplicationsharedApplication]delegate];locationManager=[[CLLocationManageralloc]init];locationManager.delegate=self;//locationManager.distanceFilter=kCLDistanceFilterNone;//wheneverwemovelocationManag

swift - CLLocationManager didUpdateLocations 仅在后台模式下被调用两次

我想使用CLLocationManager在前台和后台更新用户当前的GPS位置。我在info.plist和目标功能下注册了使用位置背景模式的应用程序。在iPhone模拟器上一切正常,但在我的真实iPhone上,当应用程序处于后台时,函数didUpdateLocations只会被调用两次。我在Xcode中使用模拟GPS数据的gpx文件。当应用程序处于前台时它会工作,我可以在MapView上看到进度。这是来self的ViewController的代码:lazyvarlocationManager:CLLocationManager!={letmanager=CLLocationManage