【问题标题】:Unable to load MKMapView in iOS 5.1无法在 iOS 5.1 中加载 MKMapView
【发布时间】:2012-04-05 02:47:34
【问题描述】:

我正在尝试在 MKMapView 中显示某个位置。加载 mapViewController 时,我在控制台中收到以下错误消息。

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

我的应用程序使用 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;
}

当我在谷歌上搜索 mapkit 教程时,我发现上面的代码来自 http://mithin.in/2009/06/22/using-iphone-sdk-mapkit-framework-a-tutorial

有人知道我为什么会收到上述错误吗?

【问题讨论】:

    标签: ios mkmapview mapkit


    【解决方案1】:

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

    【讨论】:

    • 我在项目配置中没有得到类似“特权”或类似的东西。
    猜你喜欢
    • 2011-01-25
    • 1970-01-01
    • 1970-01-01
    • 2023-04-02
    • 1970-01-01
    • 2016-10-23
    • 1970-01-01
    • 2012-09-24
    • 1970-01-01
    相关资源
    最近更新 更多