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

时间:2014-10-02 00:15:33

标签: ios ios-simulator cllocationmanager

我使用的是iOS SDK7.1。

在我的视图控制器的viewDidLoad方法中,我创建一个CLLocationManager对象并向其发送startUpdatingLocation方法。

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

但是,在CLLocationManager对象收到startUpdatindgLocation方法之后,似乎不会立即调用locationManager:didUpdateLocations。

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

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

1 个答案:

答案 0 :(得分:1)

您必须设置:

NSLocationWhenInUseUsageDescription
NSLocationAlwaysUsageDescription

在您的info.plist