0

我使用 MapKit 框架创建了一个简单的应用程序。当它启动时,用户位置被放大并显示。但是当我缩小并滚动地图时,它会在几秒钟后自动将其自身集中到用户位置。我怎样才能阻止这个?

在 m 文件中:

#import "APPNAMEViewController.h"
#import <MapKit/MapKit.h>

@synthesize mapview;

- (void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)aUserLocation     {
    mapView.scrollEnabled = YES;
    mapView.zoomEnabled = YES;
    MKCoordinateRegion region;
    MKCoordinateSpan span;
    span.latitudeDelta = 0.005;
    span.longitudeDelta = 0.005;
    CLLocationCoordinate2D location;
    location.latitude = aUserLocation.coordinate.latitude;
    location.longitude = aUserLocation.coordinate.longitude;
    region.span = span;
    region.center = location;
    [mapView setRegion:region animated:NO];
    [mapView setUserTrackingMode:MKUserTrackingModeNone animated:NO];
}
- (void)viewDidLoad
{
     [super viewDidLoad];
     mapview = [[MKMapView alloc]
           initWithFrame:CGRectMake(0,
                                    44,
                                    self.mapview.bounds.size.width,
                                    self.mapview.bounds.size.height)
           ];
     mapview.showsUserLocation = YES;
     mapview.mapType = MKMapTypeStandard;
     mapview.delegate = self;
     [mapview setUserTrackingMode:MKUserTrackingModeNone animated:NO];

     [self.view addSubview:mapview];
}

请帮我 :)

最好的问候米哈尔

4

3 回答 3

0

删除[mapView setRegion:region animated:NO];_ - (void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)aUserLocation

于 2012-04-18T10:50:33.983 回答
0
[mapView setRegion:region animated:NO]; //Changes the currently visible region and optionally animates the change.
于 2012-04-18T10:52:27.120 回答
0

删除:[mapView setUserTrackingMode:MKUserTrackingModeNone animated:NO];

这使得地图以当前位置为中心。

于 2013-12-06T20:02:17.703 回答