【发布时间】:2011-10-18 20:19:54
【问题描述】:
我正在使用 iphone 模拟器 4.2 并尝试显示或 NSLog 标题和其他位置服务属性,例如纬度、经度、高度、水平精度、垂直精度、速度。但它没有显示正确的参数并且 Incase of Heading 它实际上没有触发事件。
作为其执行 CLLocation 代码
- (void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation
{
[self.delegate locationUpdate:newLocation];
}
并且不执行 CLHeading 代码
- (void)locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading *)newHeading
{
[self.delegate headingUpdate:newHeading];
}
当我在这两个代码上设置断点时,它永远不会触及 CLHeading 代码。我正在 init 中更新位置和标题。
- (id) init{
if (self!=nil) {
self.locationManager = [[[CLLocationManager alloc] init] autorelease];
self.locationManager.delegate = self;
self.locationManager.desiredAccuracy = kCLLocationAccuracyBest;
self.locationManager.distanceFilter = kCLDistanceFilterNone;
[self.locationManager startUpdatingLocation];
[self.locationManager startUpdatingHeading];
}
return self;
}
问题是不知道是模拟器还是代码有问题?
请帮忙。
【问题讨论】:
-
这是因为模拟器没有 GPS 跟踪,因此 CLLocationManager 无法获取您的位置。
标签: iphone objective-c ios ios-simulator cllocationmanager