我无法在 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];
}
上面显示治愈的代码