我的程序在iOS7中工作正常,但不在iOS8中。 locationManager
這裏是CLLocationManager
的對象。全球定位系統位置服務不適用於iOS 8
在開始這段代碼在iOS7中工作正常,我不明白爲什麼這發生在我身上。
- (void)getCurrentLocation{
locationManager = [[CLLocationManager alloc] init];
geocoder = [[CLGeocoder alloc] init];
locationManager.delegate = self;
locationManager.distanceFilter = kCLDistanceFilterNone;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
[locationManager startUpdatingLocation];
}
#pragma mark - CLLocationManagerDelegate
- (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status{
if (status == kCLAuthorizationStatusAuthorized) {
NSUserDefaults *notify = [NSUserDefaults standardUserDefaults];
[notify setObject:@"GPS" forKey:@"Notification"];
[notify synchronize];
appDelegate = (JobDiagnosisAppDelegate *)[[UIApplication sharedApplication] delegate];
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:TRUE];
[appDelegate showIndicator];
[notify setObject:nil forKey:@"Notification"];
[notify synchronize];
}
}
- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error
{
NSLog(@"didFailWithError: %@", error);
[appDelegate.objActivityAlertView close];
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:FALSE];
appDelegate = (JobDiagnosisAppDelegate *)[[UIApplication sharedApplication] delegate];
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:TRUE];
[appDelegate showIndicator];
[self callWebserviceLocation];
}
- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
{
NSLog(@"Resolving the Address");
[geocoder reverseGeocodeLocation: locationManager.location completionHandler:
^(NSArray *placemarks, NSError *error) {
//Get address
CLPlacemark *placemark = [placemarks objectAtIndex:0];
//String to address
NSString *locatedaddress =[placemark valueForKey:@"administrativeArea"] ;
//Print the location in the console
NSLog(@"Currently address is: %@",locatedaddress);
NSUserDefaults *notifyLocation = [NSUserDefaults standardUserDefaults];
[notifyLocation setObject:locatedaddress forKey:@"notifyLocation"];
[notifyLocation synchronize];
locationManager.delegate = nil;
[self callWebserviceUnRegistered];
}];
[locationManager stopUpdatingLocation];
}
請幫忙解決這個位置問題。我是新的定位服務。
在此先感謝!
可能重複(http://stackoverflow.com/questions/24062509/ios-8-location-services-not-working) – Paulw11 2014-10-08 11:52:55