【问题标题】:is iphone Simulator capable of showing heading and latitude , longitude?iphone模拟器能显示航向和纬度,经度吗?
【发布时间】: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


【解决方案1】:

CLLocationManager 需要额外的硬件,因此无法在模拟器上运行。但是您可以使用this other SO question 中描述的方法进行测试。

来自documentation

某些定位服务需要在给定设备上安装特定硬件。例如,航向信息仅适用于包含硬件罗盘的设备。该类定义了几种方法,您可以使用这些方法来确定当前可用的服务。

【讨论】:

【解决方案2】:

可以为使用 Xcode 4.2 的任何人更新此答案。它仍处于测试状态,但如果您是付费开发者,您将可以访问它。此外,如果您是付费开发者,WWDC 2011 上有一些很好的视频,介绍了如何使用模拟器进行位置模拟。

WWDC 2011

查看核心位置的新功能并在不离开椅子的情况下测试您的位置感知应用

**注意:请再次注意,只有付费开发者才能访问这些视频

【讨论】:

    【解决方案3】:

    看起来该行为是默认的 它会触发位置,但不会触发方向。

    我尚未在实际硬件中测试我的应用程序以确认我的...

    安东尼·德萨

    【讨论】:

    • 欢迎来到 Stackoverflow。不要忘记阅读FAQ 的所有部分。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-10
    相关资源
    最近更新 更多