2016-06-14 11 views
0

Я запускаюсь в своем приложении для поиска текущего местоположения, но в первый раз вернусь вправо lat long с там зависимой локальностью, но когда они сделалиUpdateLocations, что время идет в didFailWithError и return Домен = kCLErrorDomain Code = 0 "(null)". У меня есть попробовать diffrent diffrent решения, какДомен = kCLErrorDomain Код = 0 "(null)" в любом устройстве ios

  1. Сброс содержимое и настройки
  2. В Xcode, Продукт -> Схема -> Edit Scheme, затем отменить "Разрешить Расположение Simulator" и К IOS Simulator и сброс содержимого и установите и снова на Xcode, повторите первый шаг. И к симулятору iOS и перезагрузите.

, но ни один из этой работы

мой код это не здесь:

- (void)locationManager:(CLLocationManager *)manager 
didUpdateLocations:(NSArray *)locations{ 

NSLog(@"didUpdateToLocation: %@", [locations lastObject]); 
CLLocation *currentLocation = [locations lastObject]; 


if (currentLocation != nil) 
{ 
    self.lblLongitude.text = [NSString stringWithFormat:@"%.12f", currentLocation.coordinate.longitude]; 
    self.lblLatitude.text = [NSString stringWithFormat:@"%.12f", currentLocation.coordinate.latitude]; 
} 


NSLog(@"Resolving the Address"); 


[geocoder reverseGeocodeLocation:currentLocation completionHandler:^(NSArray *placemarks, NSError *error) { 
    NSLog(@"Found placemarks: %@, error: %@", placemarks, error); 
    if (error == nil && [placemarks count] > 0) { 
     placemark = [placemarks lastObject]; 
     NSString *geoMapItem = placemark.description; 
     NSRange start = [geoMapItem rangeOfString:@"dependentLocality"]; 

     NSRange end = [geoMapItem rangeOfString:@")" options:NSCaseInsensitiveSearch range:NSMakeRange(start.location, 1000)]; 
     NSString *dataString = [geoMapItem substringWithRange:NSMakeRange(start.location, end.location - start.location + end.length)]; 
     dataString = [dataString stringByReplacingOccurrencesOfString:@"\n" withString:@""]; 
     dataString = [dataString stringByReplacingOccurrencesOfString:@" " withString:@""]; 
     dataString = [dataString stringByReplacingOccurrencesOfString:@"\"" withString:@""]; 

     start = [dataString rangeOfString:@"("]; 
     end = [dataString rangeOfString:@")"]; 
     NSLog(@"datastring===>%@",dataString); 
     lblAddress.text = [NSString stringWithFormat:@"%@ \n%@ %@\n%@\n%@", 
         dataString, 
         placemark.postalCode, placemark.locality, 
         placemark.administrativeArea, 
         placemark.country]; 
    } else 
    { 
     NSLog(@"%@", error.debugDescription); 
    } 
} ];} 

после местоположение обновлений первый раз выходит на ошибку блока

-(void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error{ 
NSLog(@"didFailWithError%@",error); 
UIAlertView *errorAlert = [[UIAlertView alloc] 
          initWithTitle:@"Error" message:@"Failed to Get Your Location" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; 
[errorAlert show];} 

и получить эту ошибку didFailWithErrorError Domain = kCLErrorDomain Code = 0 "(null)"

+0

Вы используете его на симуляторе? –

+0

Вы проверили этот ответ? http://stackoverflow.com/questions/1409141/location-manager-error-kclerrordomain-error-0 – Dominic

+0

нет, я пытаюсь использовать ipad, iphone5s, iphone6. –

ответ

0

привет Ребята, я нашел Решения моего собственного вопроса. Некоторая незначительная ошибка, сделанная мной. Я проверяю currentLocation! = Nil каждый раз, поэтому это место обновления, но текущее местоположение Lat Long не установлено.

//if (currentLocation != nil) 
//{ 
    self.lblLongitude.text = [NSString stringWithFormat:@"%.12f", currentLocation.coordinate.longitude]; 
    self.lblLatitude.text = [NSString stringWithFormat:@"%.12f", currentLocation.coordinate.latitude]; 
//} 

сейчас оно выполнено надлежащим образом.