地图视图无法添加2个以上的注释(引脚)

时间:2014-05-09 21:14:06

标签: ios mkmapview

我的应用程序中有一个地图视图,每次添加第三个注释(pin)时,它会在mainDelegate.m文件中显示ARGV运行错误?代码如下:

  [super viewDidLoad];

    MKCoordinateRegion region = { {0.0,0.0}, {0.0,0.0}};
    region.center.latitude = 53.321927;
    region.center.longitude = -6.250504;
    region.span.longitudeDelta = 0.01f;
    region.span.latitudeDelta = 0.001f;
    [mapview setRegion:region animated:YES];

    MapPin *sandford = [[MapPin alloc] init];
    sandford.title = @"Sandford Park";
    sandford.subtitle = @"Ranelagh";
    sandford.coordinate = region.center;
    [mapview addAnnotation:sandford];

    MKCoordinateRegion region2 = { {0.0,0.0}, {0.0,0.0}};
    region2.center.latitude = 53.324089;
    region2.center.longitude = -6.252080;
    region2.span.longitudeDelta = 0.01f;
    region2.span.latitudeDelta = 0.001f;
    [mapview setRegion:region2 animated:YES];

    MapPin *Cinnamon = [[MapPin alloc] init];
    Cinnamon.title = @"Cinnamon";
    Cinnamon.subtitle = @"Ranelagh";
    Cinnamon.coordinate = region2.center;
    [mapview addAnnotation:Cinnamon];

    MKCoordinateRegion region3 = { {0.0,0.0}, {0.0,0.0}};
    region3.center.latitude = 53.325010;
    region3.center.longitude = -6254461;
    region3.span.longitudeDelta = 0.01f;
    region3.span.latitudeDelta = 0.001f;
    [mapview setRegion:region3 animated:YES];

    MapPin *Gommels = [[MapPin alloc] init];
    Gommels.title = @"Gommels";
    Gommels.subtitle = @"Ranelagh";
    Gommels.coordinate = region3.center;
    [mapview addAnnotation:Gommels];

前两个工作正常但第三个每次都停止模拟器

1 个答案:

答案 0 :(得分:2)

-6254461对于经度值似乎相当大。我认为它应该是-6.254461。

你扼杀了地图的思想,它无法应对这个价值。