在我的应用程序中,我正在根据设备标题旋转 MapView,我只有一个注释,我正在旋转它的 pin 和 pinView。我的旋转方法在下一个函数内
- (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];
}
旋转功能:
- (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];
}
它正在工作,但是注释和 pinView 总是“尝试转回北方”,然后下一次当设备转身时,我的方法有效等等。我错过了什么?
谢谢