0

位置と見出しを取得する必要があります。コードを実行すると、見出しの更新のみが取得され、場所はログに表示されないため更新されません。

見出しの更新を無効にすると、位置座標が取得されます。見出しの更新がオンになっている場合、場所がわかりません。誰かが同じような問題を抱えていましたか?

これが私のセットアップルーチンと私のメソッドです:

locationManager = [[CLLocationManager alloc]init];
locationManager.headingFilter = 1;
locationManager.delegate = self;

[locationManager startUpdatingLocation];
[locationManager startUpdatingHeading];

 -(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation//          fromLocation:(CLLocation *)oldLocation 
{NSString *currentLatitude = [[NSString alloc] initWithFormat:@"%g", newLocation.coordinate.latitude];
NSLog(@"currentLatitude = %@", currentLatitude);

NSString *currentLongitude = [[NSString alloc] initWithFormat:@"%g", newLocation.coordinate.longitude];
NSLog(@"currentLongitude = %@", currentLongitude);

NSString *currentHorizontalAccuracy = [[NSString alloc] initWithFormat:@"%g", newLocation.horizontalAccuracy];
NSLog(@"currentHorizontalAccuracy = %@", currentHorizontalAccuracy);

NSString *currentAltitude = [[NSString alloc] initWithFormat:@"%g", newLocation.altitude];
NSLog(@"currentAltitude = %@", currentAltitude);

NSString *currentVerticalAccuracy = [[NSString alloc] initWithFormat:@"%g", newLocation.verticalAccuracy];
NSLog(@"currentVerticalAccuracy = %@", currentVerticalAccuracy);
}- (BOOL)locationManagerShouldDisplayHeadingCalibration: (CLLocationManager *)manager {
return NO;}


     -(void)locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading *)newHeading{
CLLocationDirection trueHeading = newHeading.trueHeading;}
4

1 に答える 1

0

ios 6.0でメソッドが更新されたため、場所が更新されていません

-(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
{
CLLocation* location = [locations lastObject];

これは、didUpdateLocations がどのように見えるかです。これで、配列が使用されます。[locations lastObject] これは、配列内の最後の既知の場所です。そこから座標などを取得できます。

于 2012-11-14T15:28:58.033 に答える