is iphone Simulator capable of showing heading and

2019-06-18 04:06发布

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 alloc] 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.

3条回答
别忘想泡老子
2楼-- · 2019-06-18 04:25

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

查看更多
乱世女痞
3楼-- · 2019-06-18 04:48

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.

查看更多
Summer. ? 凉城
4楼-- · 2019-06-18 04:49

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

查看更多
登录 后发表回答