Center the MKMapView onto my location when pressing a button

来源:互联网 发布:java歌曲管理系统代码 编辑:程序博客网 时间:2024/06/05 08:11
You could just set map view user tracking mode to MKUserTrackingModeFollow. It would automatically set map center on user location.- (IBAction)centerMapOnUserButtonClicked:(id)sender {    [self.mapView setUserTrackingMode:MKUserTrackingModeFollow animated:YES]; }


或者

[self.mapView setCenterCoordinate:self.mapView.userLocation.coordinate animated:YES];


0 0
原创粉丝点击