iOS:mapview和中心一个标记

时间:2014-04-14 15:25:57

标签: ios mkmapview marker mkmaprect

我有这个代码,在iOS6中我将一个标记放在mapview的中心,它不会发生在iOS 7中为什么?

- (void)mapView:(MKMapView *)mapView didAddAnnotationViews:(NSArray *)views {

    MKMapRect zoomRect = MKMapRectNull;
    for (id <MKAnnotation> annotation in mapView.annotations)
    {
        MKMapPoint annotationP = MKMapPointForCoordinate(annotation.coordinate);
        MKMapRect pointRect = MKMapRectMake(annotationP.x, annotationP.y, 7000, 7000);
        if (MKMapRectIsNull(zoomRect)) {
            zoomRect = pointRect;
        } else {
            zoomRect = MKMapRectUnion(zoomRect, pointRect);
        }
    }

    [mapView setVisibleMapRect:zoomRect animated:YES];

}

0 个答案:

没有答案