【发布时间】:2011-02-19 22:23:42
【问题描述】:
所以,
我正在尝试将我的应用程序移植到 iPad。 我正在使用 CoreLocation。
Apple 表示 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 模拟了我 Cupertino)。
有没有办法在模拟器(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 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
}
它是非常混乱但有效。
edit2:尝试启用您的机场,这也可以解决问题!
【问题讨论】:
标签: ios iphone ipad ios-simulator core-location