草庐IT

CLLocationManager

全部标签

ios - CLLocationManager 的 pausesLocationUpdatesAutomatically 属性在 Swift 中始终为 false (iOS8/iOS7)

我尝试在Swift中将位置管理器的pausesLocationUpdatesAutomatically设置为true,但似乎没有结果。此外,根据documentation:Thedefaultvalueofthispropertyistrue.然而,现实中的默认值似乎是假的,而且似乎没有办法将其设置为真:letmanager=CLLocationManager()println(manager.pausesLocationUpdatesAutomatically)//printsfalsemanager.pausesLocationUpdatesAutomatically=truepr

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

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

Swift,NSObject 中的 CLLocationManagerDelegate 不起作用

我在使用CLLocationDelegate获取我的位置时遇到问题。我创建了UIView的新子类并且运行良好,但是当我创建NSObject的子类时,未调用CLLocationDelegate。我可以找到问题所在。这是我的代码:importUIKitimportCoreLocationclassLocationData:NSObject,CLLocationManagerDelegate{varlocationManager:CLLocationManager=CLLocationManager()overrideinit(){super.init()ifself.locationMan

iOS:如何使用区域触发器使本地通知过期?

我有一个本地地理围栏通知,使用以下代码设置:funcstartMonitoring(annotation:MKAnnotation){letregion=CLCircularRegion(center:annotation.coordinate,radius:10.0,identifier:"randomID")region.notifyOnExit=falseletnotification=UILocalNotification()notification.region=regionnotification.alertBody="Yougotit!"notification.cate

swift - 尝试在不提示位置授权的情况下启动 MapKit 位置更新

在我的应用程序中,我使用MKMapKit和MKUserTrackingBarButtonItem来定位点击的用户。当我点击这个按钮时,输出控制台返回这个错误:TryingtostartMapKitlocationupdateswithoutpromptingforlocationauthorization.Mustcall-[CLLocationManagerrequestWhenInUseAuthorization]or-[CLLocationManagerrequestAlwaysAuthorization]first.根据我的说法,此错误是由于requestWhenInUseAu

ios - MapView 不要求位置权限

我正在尝试在Swift中构建一个mapView。它已经有效,但在我更改了一些我不记得的内容之后,我现在收到以下错误:TryingtostartMapKitlocationupdateswithoutpromptingforlocationauthorization.Mustcall-[CLLocationManagerrequestWhenInUseAuthorization]or-[CLLocationManagerrequestAlwaysAuthorization]first.NSLocationAlwaysUsageDescription在我的.plist文件中。代码如下:im

iOS 和 Swift : CLLocationManagerDelegate not updating location coordinates beyond the first location

使用以下代码,我的currentLat和currentLong不会更新到第一个位置之外。locations永远不会超过1个项目,而且总是完全相同。funclocationManager(manager:CLLocationManager,didUpdateLocationslocations:[CLLocation]){letloc:CLLocation=locations[locations.count-1]currentLat=loc.coordinate.latitudecurrentLong=loc.coordinate.longitude}我一直在做的所有搜索只显示了如果它根

ios - 如果我改变握持设备的方式,CLHeading magneticHeading 将给出不同的值

我正在使用CLHeading的magneticHeading来获取设备的航向方向,它非常准确。如果我改变设备的方向(屏幕面向x、y或z轴),那么magneticHeading的值将改变~+-15度。有没有办法解决这个问题? 最佳答案 我承认我不是专家,但我怀疑documentationforCLHeading会给你指明正确的方向(双关语不是故意的)......ThevalueinthispropertyrepresentstheheadingrelativetothemagneticNorthPole,whichisdifferen

swift - 不同的函数如何具有相同的名称?

这个问题在这里已经有了答案:Multiplefunctionswiththesamename(4个答案)关闭6年前。来自Apple'sdocumentation:RespondingtoLocationEventsfunclocationManager(CLLocationManager,didUpdateLocations:[CLLocation])Tellsthedelegatethatnewlocationdataisavailable.funclocationManager(CLLocationManager,didFailWithError:Error)Tellsthedel

ios - Swift 2 – 无法使用 CLLocationManager 获取用户位置

这是我的VC代码:importUIKitimportMapKitimportCoreLocationclassViewController:UIViewController,MKMapViewDelegate,CLLocationManagerDelegate{@IBOutletweakvarmapView:MKMapView!letlocationManager=CLLocationManager()overridefuncviewDidLoad(){super.viewDidLoad()locationManager.delegate=selflocationManager.req