2

stopUpdatingLocation が呼び出された後、灰色の gps 矢印が消えない理由がわかりません。これが私のコードです:

- (void)viewDidLoad
{
    [super viewDidLoad];

    // Do any additional setup after loading the view from its nib.
    if (self.locationManager == nil)
    {
    self.locationManager = [[[CLLocationManager alloc] init]autorelease];
    self.locationManager.desiredAccuracy = kCLLocationAccuracyBest;
    self.locationManager.delegate = self;
    }
    CLLocation *location = [self.locationManager location];
    CLLocationCoordinate2D coordinate = [location coordinate];

    g_lat = coordinate.latitude;
    g_lng = coordinate.longitude;


    [self.locationManager startUpdatingLocation];
    }

そして、ここに私のdidUpdateLocationがあります:

- (void) locationManager:(CLLocationManager *)manager didUpdateToLocation:  (CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
    {
    NSLog(@"Core location has a position.");

    CLLocationCoordinate2D coordinate = [newLocation coordinate];

    global_lat = coordinate.latitude;
    global_lng = coordinate.longitude;

    [self.locationManager stopUpdatingLocation];

    }

- (void) locationManager:(CLLocationManager *)manager
    didFailWithError:(NSError *)error
{

    NSLog(@"Core location can't get a fix.");
}

他のアプリが GPS を使用しているかどうかも確認しました。20分後、矢印はまだそこにあります....助けてくれてありがとう!

編集:

非常に重要なことを見逃していたと思います。アプリを起動して最初に表示したときに、Google マップが表示されていました。これは私のコードです:

  GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:g_lat
                                                            longitude:g_lng
                                                                 zoom:15];



    self.mapView = [GMSMapView mapWithFrame:CGRectMake(1.0f, 160.0f, 320.0f, 100)
                                     camera:camera];

    self.mapView.delegate = self;
    self.showsUserLocation = YES;
    self.mapView.trafficEnabled = YES;
    self.mapView.myLocationEnabled = YES;
    self.mapView.settings.myLocationButton = YES;
    self.mapView.settings.compassButton = YES;
    [self.mapView setUserInteractionEnabled:YES];
    [self.mapView setCamera:camera];

    [self.containerView addSubview:self.mapView];

グーグルマップが常に更新されている可能性はありますか?はいの場合、どうすればそれを止めることができますか?

4

1 に答える 1