2010-07-03 54 views
1

在Xcode的最新版本中,set region工作正常,现在在3.2.3中它不会捕捉到指定的区域?在3.2.3/OS4中破解的MKMapView - 无法设置区域

查看做负载后...

[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]; 

这是工作得很好,现在没有捕捉到上述表示的位置代码,它只是显示世界地图。

任何帮助非常感谢。

回答

0

我在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:方法传递区域只是一个好习惯。