【问题标题】:Core Location in iPhone Simulator 3.2 (iPad)iPhone Simulator 3.2 (iPad) 中的核心位置
【发布时间】: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


    【解决方案1】:

    您可能还想查看我的FTLocationSimulator

    它会读取由 Google 地球生成的 KML 文件,以提供持续的位置更新。它还使用模拟的位置更新更新 MKMapView 中的蓝色 userLocation 点。

    【讨论】:

    • 是的,我认为是在最新的 macoun 上看到的 ;)
    • 你参加了我的演讲? - 太好了,我感到很荣幸! :)
    【解决方案2】:

    是的,请参阅this question,其中有几个很好的答案。

    编辑 - 我最终决定编写自己的 CLLocationManager 模拟器,以便在 iPhone 模拟器上进行测试。如果你想使用它,它位于github here

    【讨论】:

    • 所以ipad模拟器默认不给我位置?
    • 用您的链接处理它。看看我的问题帖子,看看我是如何处理它的。
    • @choise:我今天刚刚发现,当您在 Mac 上关闭机场 (Wi-Fi) 时,模拟器不会提供位置。至少在 XCode 3.2.3 中是这样的。
    • 嗯,我的机场已禁用,是的。谢谢!我试试看。
    • @progrmr,感谢您发现这一点,我正在努力找出为什么除了我之外每个人都获得了 Cupertino 的位置。虽然不是很环保:我现在必须打开我的机场卡并用电,尽管我不将它用于其他任何事情(我使用网卡访问互联网)。
    【解决方案3】:

    根据iPhone Development Guide,模拟器中的位置是固定的。对不起!

    【讨论】:

    • 那不是我的问题。在 3.2 上,模拟器中的核心定位不起作用。没有“cupertino 模拟”。我编辑了我的问题
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多