2013-06-27 55 views
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]; 
     }]; 
    } 
} 

回答

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

    double rotation = newHeading.magneticHeading * 3.14159/180; 

    [_compass_image setTransform:CGAffineTransformMakeRotation(-rotation)]; 

} 
+0

歡迎兄弟,,,,。 –