2012-12-06 4 views
0

안녕하세요,지도 애플리케이션에서 작업 중입니다. 나는 mapview와 imageview를 회전시키고 있는데, 그것은 annotationView에서 서브 뷰이다. 지도 뷰 회전은 완벽하지만 이미지 뷰는지도 뷰에 따라 회전하지 않으며 항상 북쪽 방향을 가리 킵니다.지도의 맞춤 이미지 뷰가 아이폰의 MapView와 함께 회전하지 않습니다.

-(MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation 

{ 

static NSString *identifier = @"annView"; 

MKPinAnnotationView *annView = (MKPinAnnotationView *) [self.mapView dequeueReusableAnnotationViewWithIdentifier:identifier]; 

annView=nil; 
[annView setSelected:YES animated:NO]; 
if (annView == nil) 
{ 
    annView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:identifier]; 
} 

MyAnnotation *myAnnotation=(MyAnnotation *)annotation; 
NSString *details; 
if ([myAnnotation isKindOfClass:[MKUserLocation class]]) 
{ 
    //return nil; 
} 
else 
{ 
    details=[myAnnotation annType]; 

} 
NSLog(@"Details is %@",details); 
annView.canShowCallout = YES; 

if([details isEqualToString:@"Current"]) 
{ 
    [[annView subviews] makeObjectsPerformSelector:@selector(removeFromSuperview)]; 
    annView.animatesDrop=NO; 
    annView.canShowCallout=YES;//pin3.png// Parking_Psymbol//dus2 
    annView.image=[UIImage imageNamed:@""]; 
    UIImage * locaterImage; 
    locaterImage = [UIImage imageNamed:@"Locatermap.png"]; 

    locaterImageView = [[UIImageView alloc] initWithImage:locaterImage]; 
    locaterImageView.frame = CGRectMake(-28, -4, 70, 70); 

    //--------For animating imageview --------------------- 

    // Setup the animation 
    [UIView beginAnimations: @"anim" context: nil]; 
    [UIView setAnimationDuration:2.0]; 
    [UIView setAnimationCurve:2.0]; 
    //[UIView setAnimationRepeatCount:10]; 
    [UIView setAnimationBeginsFromCurrentState:YES]; 
      [UIView setAnimationDelegate:self]; 
    [UIView commitAnimations]; 
    //--------For animating imageview --------------------- 
    [annView addSubview:locaterImageView]; 
} 

를 그리고지도보기를 회전 :

나는 회전 이미지 뷰에 대한 코드 아래 사용하고

-(void)locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading *)newHeading 

{ 

// Convert Degree to Radian and move the needle 
float oldRad = -manager.heading.trueHeading * M_PI/180.0f; 
float newRad = -newHeading.trueHeading * M_PI/180.0f; 

CABasicAnimation *theAnimation; 
theAnimation=[CABasicAnimation animationWithKeyPath:@"transform.rotation"]; 
theAnimation.fromValue = [NSNumber numberWithFloat:oldRad]; 
theAnimation.toValue=[NSNumber numberWithFloat:newRad]; 
theAnimation.duration = 0.5f; 
[mapView.layer addAnimation:theAnimation forKey:@"transform.rotation"]; 
self.mapView.transform = CGAffineTransformMakeRotation(newRad); 
} 

내가 봤,하지만 난 내 필요한 답을 찾을 수 없습니다. 이 문제를 해결할 아이디어를주십시오.

미리 감사드립니다.

답변

0

지도를 회전하면 실제 세계와 일치하게됩니다. 나는. 지도의 북쪽이 실제로 북쪽을 가리키고 있습니까? 그렇다면 당신이해야 할 일은 MKMapViewuserTrackingMode에서 MKUserTrackingModeFollowWithHeading

+0

내가 분명히 이해하지 못했던 것입니다. –

+0

왜지도를 회전시키고 있습니까? 지도의 북쪽이 북극을 향하도록지도를 회전 시키시겠습니까? – Craig

관련 문제