如何检查iPhone上的地理位置是否已启用?
问题描述:
如何检查iPhone上的本地化是否启用?如何检查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];
}
//委托本地化 - (空)的LocationManager:(CLLocationManager *)经理 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];
}
这不是本地化。这是地理位置。 – BoltClock 2011-06-15 17:19:52
谢谢。我纠正了它 – Dany 2011-06-15 17:22:18