如何放大并将用户位置“点”居中?我已经尝试了在这里和其他网站上找到的所有内容,但我似乎无法做到正确。
请帮助我!
编辑:我尝试在 viewDidAppear 中实现这行代码。我在某处的旧线程中找到了它,但它似乎不再起作用了......
[mapView setCenterCoordinate:mapView.userLocation.location.coordinate animated:YES];
最佳答案
我以编程方式创建了 map ,而不是使用 MapKit View ,它运行得非常好!
代码如下:
[super viewDidLoad];
self.mapView = [[MKMapView alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height)];
[self.mapView setShowsUserLocation:YES];
[self.mapView setDelegate:self];
[self.view addSubview:self.mapView];
[mapView setMapType:MKMapTypeHybrid];
}
#pragma mark - MKMapViewDelegate Methods
- (void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation {
[self.mapView setRegion:MKCoordinateRegionMake(userLocation.coordinate, MKCoordinateSpanMake(0.1f, 0.1))animated:YES];
}
关于ios - 如何放大和居中用户位置(Objective-C),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30414968/