【问题标题】:How to check if geolocation is enabled on iPhone?如何检查 iPhone 上是否启用了地理定位?
【发布时间】:2011-09-15 17:45:57
【问题描述】:

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

}

【问题讨论】:

  • 那不是本地化。这就是地理位置。

标签: objective-c uitableview geolocation uiactivityindicatorview


【解决方案1】:

【讨论】:

  • 虽然,这不会检查它是否仅对当前应用程序启用。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-08-22
  • 2016-04-24
  • 1970-01-01
  • 2011-06-18
  • 2011-12-07
相关资源
最近更新 更多