0

我正在制作一个每 5 度旋转一次的指南针,但问题是当用户将设备旋转超过 5 度时,我会同时收到多个响应,并且在最后一次之前,旋转设备的方法将被调用多次一个会完成,因此它不会为指南针提供顺畅的方式。最后一个完成后如何旋转指南针?

- (void)locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading *)newHeading
{
    if (newHeading.headingAccuracy > 0) {
       /* Rotate the compass to the selected degree */
       [UIView animateWithDuration:1.0f animations:^{
           [self.compassImageView rotateByDegree:degree clockWise:YES];
       }];
    }
}
4

1 回答 1

1
- (void)locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading *)newHeading
{
//    [manager stopUpdatingHeading];

    double rotation = newHeading.magneticHeading * 3.14159 / 180;

    [_compass_image setTransform:CGAffineTransformMakeRotation(-rotation)];

}
于 2013-06-27T13:32:17.533 回答