本文介绍了如何更改视图,而我们接触任何注解的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在的MKMapView添加功能。
I want to add a functionality in MKMapView .
我有很多注释的图形页面现在我想的..当我接触任何注解整个视图应侧重于注释。即注解的是在右上角,当我接触到的MapView应表明,在中心即可。
I have a mapView with many annotations now I want that .. when I touch any annotation the whole view should be focus on that annotation . i.e. annotation A is in the upper right corner and when I touch that the MapView should show that A in the centre then .
推荐答案
在注释代表你必须设置香港特别行政区的MapView指定中心
In Annotation Delegate you have to set the Region for mapview specifying the center
- (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view
{
MKAnnotation *annotation= view.annotation; // Get your annotaion here
MKCoordinateRegion region = { {0.0, 0.0 }, { 0.0, 0.0 } };
region.center.latitude=annotation.coordinate.latitude;
region.center.longitude=annotation.coordinate.longitude;
region.span.latitudeDelta=0.001f;
region.span.longitudeDelta=0.001f;
[mapView setRegion:region animated:YES];
//Do your other stuffs here
}
这篇关于如何更改视图,而我们接触任何注解的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!