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。 –