iOS 模拟器、CLLocationManager、startUpdatingLocation 和 locationManager :didUpdateLocations

标签 ios ios-simulator cllocationmanager

我正在使用 iOS SDK7.1。

在我的 View Controller 的 viewDidLoad 方法中,我创建了一个 CLLocationManager 对象并将它发送给 startUpdatingLocation 方法。

在 iOS 模拟器中,我可以更改位置,然后调用 locationManager:didUpdateLocations。

但是,似乎并没有在CLLocationManager对象接收到startUpdatindgLocation方法后立即调用locationManager:didUpdateLocations。

在 CLLocationManger 中 startUpdatingLocation 的文档中说: 调用此方法会导致位置管理器获取初始位置修复(这可能需要几秒钟)并通过调用其 locationManager:didUpdateLocations: 方法通知您的委托(delegate)。

基本上,我想在用户移动之前获取用户的位置。

最佳答案

你必须设置:

NSLocationWhenInUseUsageDescription
NSLocationAlwaysUsageDescription

在你的 info.plist 中

关于iOS 模拟器、CLLocationManager、startUpdatingLocation 和 locationManager :didUpdateLocations,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26152679/

相关文章:

ios - 为什么在 iOS Swift : unexpectedly found nil while unwrapping an Optional value? 中尝试向服务器发出发布请求时出现此错误

ios - 执行 push segue 后没有出现“后退”按钮

ios - collectionView 图片 : Change Height Dynamically in Swift

ios - 旋转 SCNCamera 节点,观察一个假想球体周围的物体

iphone - 以编程方式查找 iPhone 应用程序标识符前缀

objective-c - 具有 iPad 视网膜显示屏的模拟器

ios-simulator - iOS模拟器无法安装应用程序

swift - 用户在 Swift 中禁用位置时如何显示警报?

ios - 地理围栏 iOS 6

Swift CLAuthorizationStatus 总是 CLAuthorizationStatus.NotDetermined