這是警報後訪問您的當前位置,這將自動在您訪問使用CLLocationManager
-(void)getLocation
{
locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
locationManager.distanceFilter = kCLLocationAccuracyHundredMeters;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
NSLog(@"eee%f",locationManager.location.coordinate.latitude);
// Start updating location changes.
[locationManager startUpdatingLocation];
}
- (void)startUpdatingCurrentLocation
{
//NSLog(@"STARTUPDATELOCATION");
// if location services are restricted do nothing
if ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusDenied ||
[CLLocationManager authorizationStatus] == kCLAuthorizationStatusRestricted)
{
return;
}
// if locationManager does not currently exist, create it
if (!locationManager)
{
locationManager = [[CLLocationManager alloc] init];
[locationManager setDelegate:self];
locationManager.distanceFilter = 10.0f; // we don't need to be any more accurate than 10m
}
[locationManager startUpdatingLocation];
// [self showCurrentLocationSpinner:YES];
}
更多信息
剛看完
CLLocationManager Class Reference用戶當前的位置問