我試圖表明我的當前位置在Mapkit這是代碼CoreLocation,MapKit錯誤
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
//Make this controller the delegate for the map view.
self.MapView.delegate = self;
// Ensure that you can view your own location in the map view.
[self.MapView setShowsUserLocation:YES];
locationManager = [[CLLocationManager alloc] init];
[locationManager setDelegate:self];
[locationManager setDistanceFilter:kCLDistanceFilterNone];
[locationManager setDesiredAccuracy:kCLLocationAccuracyBest];
}
,我寫了這個委託的Mapkit
#pragma mark - MKMapViewDelegate methods.
- (void)mapView:(MKMapView *)mv didAddAnnotationViews:(NSArray *)views {
MKCoordinateRegion region;
region = MKCoordinateRegionMakeWithDistance(locationManager.location.coordinate,2000,2000);
[mv setRegion:region animated:YES];
}
,但我得到錯誤的位置蔭在埃及和這給美國Iam在美國 任何一個可以幫我ME?
如何將它設置到埃及? – user1752619
你必須輸入你的位置的經度和緯度。所以,啓動模擬器,去調試 - >位置 - >自定義位置,並將其設置爲30.2,31.5 – Nicholas
BIG謝謝尼古拉斯:) 我做這個,它顯示我在地圖上埃及但不是當前位置 – user1752619