2012-04-04 92 views
1

我想在MKMapView中显示一些位置。加载mapViewController时,我在控制台中收到以下错误消息。无法在iOS 5.1中加载MKMapView

__GEORegisterNetworkDefaults_block_invoke_0:无法连接到geod上com.apple.geod.defaults

我使用的Xcode 4.3和iOS 5.1我的应用程序。

我使用下面的代码来显示地址:

- (void) showAddress 
{ 
    MKCoordinateRegion region; 
    MKCoordinateSpan span; 
    span.latitudeDelta = 0.2; 
    span.longitudeDelta = 0.2; 

    CLLocationCoordinate2D location = [self addressLocation]; 
    region.span = span; 
    region.center = location; 
} 

而从下面的代码获取地址位置。

-(CLLocationCoordinate2D) addressLocation 
{ 
    NSString *urlString = [NSString stringWithFormat:@"http://maps.google.com/maps/geo?q=%@&output=csv", 
          [@"cupertino" stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; 
    NSError *err; 
    NSString *locationString = [NSString stringWithContentsOfURL:[NSURL URLWithString:urlString] encoding:NSUTF8StringEncoding error:&err]; 
    NSArray *listItems = [locationString componentsSeparatedByString:@","]; 

    double latitude = 0.0; 
    double longitude = 0.0; 

    if([listItems count] >= 4 && [[listItems objectAtIndex:0] isEqualToString:@"200"]) 
    { 
     latitude = [[listItems objectAtIndex:2] doubleValue]; 
     longitude = [[listItems objectAtIndex:3] doubleValue]; 
    } 

    CLLocationCoordinate2D location; 
    location.latitude = latitude; 
    location.longitude = longitude; 

    return location; 
} 

当我google一下了mapkit教程后来我发现从http://mithin.in/2009/06/22/using-iphone-sdk-mapkit-framework-a-tutorial

上面的代码中没有人知道为什么我收到上述错误?

回答

1

您是否告诉XCode您的应用需要访问位置信息?我认为这是'特权'或类似的项目配置。

+0

我在项目配置中没有得到像'privileges'或类似的东西。 – 2012-04-06 06:13:22