In my app I'm rotating the MapView according to the device heading, I have only one annotation and i'm rotating it's pin and it's pinView too. My rotation method is inside the next function
- (void)locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading *)newHeading {
if (newHeading.headingAccuracy < 0)
return;
CLLocationDirection theHeading = ((newHeading.trueHeading > 0) ?
newHeading.trueHeading : newHeading.magneticHeading);
lastHeading = theHeading;
[self rotateImage:self.mapView duration:0.1 degrees:-theHeading];
[self rotateImage:jerusalemPinView duration:0.1 degrees:theHeading];
}
Rotation function:
- (void)rotateImage:(UIView *)view duration:(NSTimeInterval)duration
degrees:(double)angleDegrees
{
// Setup the animation
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:duration];
[UIView setAnimationBeginsFromCurrentState:YES];
// The transform matrix
CGAffineTransform transform =
CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(angleDegrees));
view.transform = transform;
[UIView commitAnimations];
}
it's working but then annotation and pinView are always "try to turn back to the north", then the next time when the device is being turned around my method works and so on.. What am i missing?
Thanks