我是一名注册的iOS开发人员.如何将我的iPhone应用程序转移到我的个人iPhone?
当我开始我的应用程序新鲜,或在很长一段时间后恢复,MKMapView的userLocation的概念是错误的,并显示我在海中.
我使用以下代码:
self.mapView.centerCoordinate = self.mapView.userLocation.location.coordinate;
[mapView setCenterCoordinate:self.mapView.userLocation.location.coordinate zoomLevel:ZOOM_LEVEL animated:YES];
Run Code Online (Sandbox Code Playgroud)
经过漫长的应用程序简历或全新的开始......
我已阅读并按照说明如何在没有CLLocationManager的情况下将MKMapView缩放到用户当前位置?
然而,虽然我确实得到了当前的用户位置,但我实际上无法使地图在视觉上居中.
例如,在viewDidLoad函数中,如何使地图围绕用户已知位置进行可视化居中?我已粘贴下面CurrentLocation的代码(请参阅viewDidLoad中的XXX注释
#import "MapViewController.h"
#import "PlacemarkViewController.h"
@implementation MapViewController
@synthesize mapView, reverseGeocoder, getAddressButton;
- (void)viewDidLoad
{
[super viewDidLoad];
// XXX HERE: How can I cause self.mapView to actually recenter itself at self.mapview.userLocation.location?
mapView.showsUserLocation = YES;
}
- (void)viewDidUnload
{
self.mapView = nil;
self.getAddressButton = nil;
}
- (void)dealloc
{
[reverseGeocoder release];
[mapView release];
[getAddressButton release];
[super dealloc];
}
- (IBAction)reverseGeocodeCurrentLocation
{
self.reverseGeocoder =
[[[MKReverseGeocoder alloc] initWithCoordinate:mapView.userLocation.location.coordinate] autorelease];
reverseGeocoder.delegate = self;
[reverseGeocoder start];
}
- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFailWithError:(NSError *)error
{ …Run Code Online (Sandbox Code Playgroud)