所以,我正在尝试将我的应用移植到iPad上。我正在使用CoreLocation。
苹果表示iPad确实具有
Location:
Wi-Fi
Digital compass
Assisted GPS (Wi-Fi + 3G model)
Cellular (Wi-Fi + 3G model)
因此,应该可以获取我的iPad(至少带有3G模型)的位置,大约为3公里半径就足够了。
但在模拟器中(3.2 iPad),它不起作用(在模拟器中运行3.1.3会模拟出库比蒂诺)。
有没有办法在模拟器中(3.2 iPad)获取位置? 我住在德国,在这里iPad还没有发布,所以我无法在我的设备上测试它。
谢谢!
编辑
这就是我尝试获取连接的方式
locationManager = [[CLLocationManager alloc] init];
locationManager.desiredAccuracy = kCLLocationAccuracyThreeKilometers;
locationManager.delegate = self;
[locationManager startUpdatingLocation];
在3.2版本中,locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error
总是会被调用,在3.1.3版本中则不会。
error
对象的格式如下:
Error Domain=kCLErrorDomain Code=0 "Operation could not be completed. (kCLErrorDomain error 0.)"
编辑
所以我处理它的方式大致是这样的:
- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error {
#ifdef TARGET_IPHONE_SIMULATOR
// Cupertino
CLLocation *simulatorLocation = [[CLLocation alloc] initWithLatitude:37.33168900 longitude:-122.03073100];
[self locationManager:locationManager didUpdateToLocation:simulatorLocation fromLocation:nil];
[simulatorLocation release];
#else
[[NSNotificationCenter defaultCenter] postNotificationName:@"ErrorNotification" object:NSLocalizedString(@"GPS-coordinates could not be detected",@"")];
#endif
}
虽然很混乱,但它确实有效。
编辑2:尝试启用您的机场,这也可能解决问题!