开发者

is iphone Simulator capable of showing heading and latitude , longitude?

I am using iphone simulator 4.2 and try to display or NSLog Heading and other Location services attributes e.g. Latitude, Longitude, altitude, horizontalAccuracy, VerticalAccuracy, speed. but its not showing the correct parameters and Incase of Heading its actually not firing the event. as its execute CLLocation code

- (void)locationManager:(CLLocationManager *)manager
    didUpdateToLocation:(CLLocation *)newLocation
           fromLocation:(CLLocation *)oldLocation
{
    [self.delegate locationUpdate:newLocation];
}

and not executing CLHeading code

- (void)locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading *)newHeading
{
    [self.delegate headingUpdate:newHeading];
}

and when I put breakpoint on these both codes it never touch CLHeading code. I am updating location and heading in init.

- (id) init{
if (self!=nil) {
    self.locationManager  = [[[CLLocationManager al开发者_运维技巧loc] init] autorelease];
    self.locationManager.delegate = self;
    self.locationManager.desiredAccuracy = kCLLocationAccuracyBest;
    self.locationManager.distanceFilter = kCLDistanceFilterNone;
    [self.locationManager startUpdatingLocation];
    [self.locationManager startUpdatingHeading];
}
return self;
}

The problem is that I do not know that is due to simulator or there is any problem in code?

please help.


CLLocationManager needs additional hardware and hence wont work on simulator. However you can test that using the method described in this other SO question.

From the documentation:

Some location services require the presence of specific hardware on the given device. For example, heading information is available only for devices that contain a hardware compass. This class defines several methods that you can use to determine which services are currently available.


This answer can be updated for anyone using Xcode 4.2. It is still in beta status, but if you are a paid developer you will have access to it. Also, if you are a paid developer, there are some good videos from WWDC 2011 that explain how to use the simulator for location simulation.

WWDC 2011

See What's New in Core Location and Testing Your Location-Aware App Without Leaving Your Chair

**Note: Please note again that only paid developers have access to these videos


It looks like the behaviour is by default It fires Location but not heading.

I have not tested my application in actual hard ware to confirm my though...

Anthony Desa

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜