進出口工作在一個MapView但它不顯示用戶的位置就像我想,也是引腳,我不知道該代碼是正確的,我覺得是的,所以我需要你的幫助。MapView不顯示位置和引腳?
繼承人用於顯示的變焦位置代碼:
- (void)viewDidLoad
{
self.MapView.showsUserLocation = YES;
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];
coordinateuser.latitude = self.MapView.userLocation.coordinate.latitude;
coordinateuser.longitude = self.MapView.userLocation.coordinate.longitude;
MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(coordinateuser, 1200, 1200);
double delayInSeconds = 2.0;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
[self.MapView setRegion:region animated:YES];
});
[super viewDidLoad];
}
而且繼承人用於顯示MKPinAnnotationView的代碼,這是一個,我認爲是錯誤的:
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation{
static NSString *SFAnnotationIdentifier = @"SFAnnotationIdentifier";
MKPinAnnotationView *pinView =
(MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:SFAnnotationIdentifier];
if (!pinView)
{
MKAnnotationView *annotationView = [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:SFAnnotationIdentifier];
return annotationView;
}
else
{
pinView.annotation = annotation;
}
cmtlocation = CLLocationCoordinate2DMake(19.502519,-99.259779);
//UIImage *flagImage = [UIImage imageNamed:@"flag.png"];
//annotationView.image = flagImage;
[annotation setCoordinate:cmtlocation];
return pinView;
}
所以我將感謝您的幫助!謝謝!