2013-09-04 2 views
2

자전거/자동차 이미지를 사용자의 방향으로 회전시키고 싶습니다. 지금 이미지가 방향을 따라하지만 비 지시어를 보이는, 우리는 지점이 방향을 따라하지 않는 말할 수있다 :지도에서 사용자 방향에 따라 이미지 회전

- (MKAnnotationView *)mapView:(MKMapView *)map viewForAnnotation:(id <MKAnnotation>)annotation 
{ 
    static NSString *AnnotationViewID = @"annotationViewID"; 

    MKAnnotationView *annotationView = (MKAnnotationView *)[map dequeueReusableAnnotationViewWithIdentifier:AnnotationViewID]; 

    if (annotationView == nil) 
    { 
     annotationView = [[[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:AnnotationViewID] autorelease]; 
    } 

    annotationView.image = [UIImage imageNamed:@"Bike.png"]; 
    annotationView.annotation = annotation; 

    return annotationView; 
} 

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation 
{ 
    if (newLocation.horizontalAccuracy < 0) 
     return; 
    if (!newLocation) 
     return; 

    currentLocation = newLocation; 
    if(currentLocation != nil) 
    { 

     if (myAnnotation) 
     { 
      [self.myMapView removeAnnotation:myAnnotation]; 
     } 

     CLLocationCoordinate2D location = CLLocationCoordinate2DMake(currentLocation.coordinate.latitude, currentLocation.coordinate.longitude); 
     myAnnotation = [[MyAnnotation alloc] initWithCoordinates:location title:@"Current Location" subTitle:nil]; 
     [self.myMapView addAnnotation:myAnnotation]; 
    } 
} 

답변

1

체크 아웃 핵심 위치의 -[CLLocationManagerDelegate locationManager:didUpdateHeading:]을.

관련 문제