是iPhone模拟器能够显示标题和纬度,经度?

我正在使用iphone模拟器4.2,并尝试显示或NSLog标题和其他位置服务的属性,如经度,纬度,高度,水平精度,VerticalAccuracy,速度。 但它没有显示正确的参数和标题,实际上并没有发射事件。 作为它的执行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; } 

问题是,我不知道是由于模拟器或代码中有任何问题?

请帮忙。

CLLocationManager需要额外的硬件,因此不会在模拟器上工作。 但是,您可以使用在其他SO问题中描述的方法来testing。

从文档 :

一些位置服务需要在给定设备上存在特定的硬件。 例如,标题信息仅适用于包含硬件指南针的设备。 这个类定义了几个方法,可以用来确定哪些服务当前可用。

这个答案可以更新为任何使用Xcode 4.2的人。 它仍处于testing版状态,但如果您是付费开发者,则可以访问它。 另外,如果您是付费开发者,则可以从WWDC 2011获得一些很好的video,解释如何使用模拟器进行位置模拟。

WWDC 2011

查看核心位置的新增function,并在不离开主席的情况下testing您的位置感知应用程序

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

它看起来像行为是默认情况下,它会触发位置,而不是标题。

我没有在实际的硬件上testing我的应用程序来确认我的…

安东尼·德萨