0
我在我的應用程序中運行以查找當前位置,但第一次返回右拉特隆,並且存在依賴位置,但是當他們執行了UpdateLocations時間到了didFailWithError和返回Domain = kCLErrorDomain Code = 0「(null)」。我也嘗試像在任何ios設備中,域= kCLErrorDomain代碼= 0「(null)」
- 重置內容和設置不同勢不同勢解決方案
- 在Xcode中,產品展示 - >計劃 - >編輯 方案,然後取消「允許位置模擬器」,並要了iOS 模擬器和重置內容並重新設置並重新登錄到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)」
你在模擬器上運行它嗎? –
你看看這個答案嗎? http://stackoverflow.com/questions/1409141/location-manager-error-kclerrordomain-error-0 – Dominic
不,我想在ipad,iphone5s,iphone6。 –