【问题标题】:MKMapView broken in 3.2.3 / OS4 - Can't set regionMKMapView 在 3.2.3 / OS4 中损坏 - 无法设置区域
【发布时间】:2011-03-11 11:28:59
【问题描述】:

在 Xcode 的最后一个版本中,设置区域工作正常,现在在 3.2.3 中它不会捕捉到您指定的区域?

View 加载后...

 [mapView setMapType:MKMapTypeHybrid];
 [mapView setZoomEnabled:YES];
 [mapView setScrollEnabled:YES];

 MKCoordinateRegion region = { {0.0, 0.0 }, { 0.0, 0.0 } };
 region.center.latitude = 41.902245099708516;
 region.center.longitude = 12.457906007766724;
 region.span.longitudeDelta = 0.04f;
 region.span.latitudeDelta = 0.04f; 
 [mapView setRegion:region animated:YES];

 [mapView setDelegate:self];

这是运行良好的代码,现在它不会捕捉到上面指出的位置,它只是显示世界地图。

非常感谢任何帮助。

【问题讨论】:

    标签: iphone xcode sdk xcode3.2


    【解决方案1】:

    我在 3.2.3 和 iOS4 中做了很多。我保证它有效。

    我喜欢MKCoordinateRegionMakeWithDistance()

    CLLocationCoordinate2d coord = { 41.902245099708516, 12.457906007766724 };
    MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(coord, 1000, 1000);
    [mapView setRegion:[mapView regionThatFits:region] animated:YES];
    

    第二个和第三个参数中的“1000, 1000”是该区域范围分量的纬度和经度米。通过 mapview 的 -regionThatFits: 方法传递区域只是一个好习惯。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-01-30
      • 2016-04-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多