0

在此处输入图像描述我无法在 iOS 6.0.1 中获取当前位置,![当我尝试获取当前位置时,请查看屏幕截图地图视图未显示它只是显示空白地图屏幕我当前位置的纬度经度都是正确的

我的代码如下: -

  //Start fetching logged in user current location
    self.m_LocationManager = [[CLLocationManager alloc] init];
    self.m_LocationManager.distanceFilter = kCLDistanceFilterNone;
    self.m_LocationManager.desiredAccuracy = kCLLocationAccuracyHundredMeters;
    self.m_LocationManager.delegate = self;

    [self.m_LocationManager startUpdatingLocation];

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {

    [manager stopUpdatingLocation];

    self.m_LatitudeValue = newLocation.coordinate.latitude;
    self.m_LongitudeValue = newLocation.coordinate.longitude;

    NSLog(@"lat %f long %f",self.m_LatitudeValue,self.m_LongitudeValue);
}


//for showing current location

- (void)addAnnotations { 

    MKCoordinateSpan span;
    span.latitudeDelta=0.08;
    span.longitudeDelta=0.08;


    Social_Check_InAppDelegate *appDelegate = (Social_Check_InAppDelegate *)[[UIApplication sharedApplication] delegate];

    //user current location
        double latitudeValue = appDelegate.m_LatitudeValue;
        double longitudeValue = appDelegate.m_LongitudeValue;



    CLLocationCoordinate2D coardinate1 = {latitudeValue,longitudeValue};
    MKCoordinateRegion region;
    region.center=coardinate1;
    region.span=span;

    CSMapAnnotation *ann = [[CSMapAnnotation alloc]initWithCoordinate:coardinate1];
    ann.title = m_PlacesNameString;
    ann.type = @"green";

    [m_MapView setRegion:region animated:TRUE];
    [m_MapView regionThatFits:region];
    [m_MapView addAnnotation:ann];

    [ann release];
}

上面显示治愈的代码

4

1 回答 1

0

这可能是因为 iOS 6 不支持

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation 

方法。请检查文档。上述方法已弃用。在 iOS 6 及更高版本中,位置管理器在事件locationManager:didUpdateLocations:可用时将事件报告给其委托的方法。

于 2013-02-06T07:40:03.507 回答