【发布时间】:2015-01-02 19:52:42
【问题描述】:
我正在尝试使用 iOS 模拟器中的选项:debug->freeway drive/city run 来模拟位置更新。
在我的代码中,我使用CLLocationManager 通过以下代码获取位置更新:
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
[locationManager setDesiredAccuracy:kCLLocationAccuracyNearestTenMeters];
[locationManager setDistanceFilter:20];
}
-(void)viewWillAppear:(BOOL)animated {
[locationManager startUpdatingLocation];
}
-(void)locationManager:(CLLocationManager *)lm didUpdateLocations:(NSArray *)locations{
CLLocation *location = [locations lastObject];
NSLog(@"Location returned: %f, %f Accuracy: %f", location.coordinate.latitude, location.coordinate.longitude, location.horizontalAccuracy);
}
当我的应用程序在后台并且我在模拟器中选择选项时,我从来没有收到关于位置更新的委托回调。
我为我的应用提供了位置更新的后台模式。请让我知道如何准确使用这些功能,或者我是否在这里遗漏了什么。
【问题讨论】:
标签: ios ios-simulator core-location cllocationmanager