Как проверить, включена ли локализация на iPhone?
Мне нужно проверить, включена ли геолокация в методе viewDidLoad.
Это мой метод viewDidLoad:
- (void)viewDidLoad {
[super viewDidLoad];
// 1. Check connection
[self performSelector:@selector(checkConnection)];
// 2. Loader (activity indicator) ...
progressViewController = [[ProgressViewController alloc] initWithNibName:@"ProgressViewController" bundle:nil];
[self.view addSubview:progressViewController.view];
// 3. Active geolocation
locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
[self startGps];
// 4. Data tableView
NSMutableArray *arrEvents = [[NSMutableArray alloc] init];
[[ListaEventiSingleton sharedListaEventi] setArrEvents:arrEvents];
[arrEvents release];
// 5. remove loader (activity indicator)
[progressViewController.view removeFromSuperview];
}
// локализация делегата - (void) locationManager: (CLLocationManager *) manager didUpdateToLocation: (CLLocation *) newLocation fromLocation: (CLLocation *) oldLocation {
if (newLocation.horizontalAccuracy < 0) {
locality = @"Non riesco a localizzarti..\n Refresha!";
}
else {
CLLocationCoordinate2D here = newLocation.coordinate;
latitudine = [NSString stringWithFormat:@"%f", here.latitude];
longitudine = [NSString stringWithFormat:@"%f", here.longitude];
[self getAddressFromGmaps];
[self stopGps];
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(stopUpdatingLocalizzazione) object:nil];
}
labelLocality.text = locality;
// 4. Load data for the table view
[self performSelectorOnMainThread:@selector(loadEvents) withObject:nil waitUntilDone:YES];
[tableViewEvents reloadData];
// 5. remove activity indicator
[progressViewController.view removeFromSuperview];
}