1

如何檢查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]; 

}

+0

這不是本地化。這是地理位置。 – BoltClock 2011-06-15 17:19:52

+0

謝謝。我糾正了它 – Dany 2011-06-15 17:22:18

回答

相關問題