2013-06-26 52 views
0

可能是我錯過了我在學校的數學課,但無法弄清楚這一點。如何糾正由landscapeLeft模式下旋轉設備引起的圖像翻轉

我正在讀取來自加速度計和旋轉圖像的數據有關加速計數據。一切與LandscapeRight一起工作,但在landscapeLeft我的imageView翻轉顛倒。我該如何解決這個問題?

簡化代碼波紋管:

- (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration 
{ 

    double accelerationX = acceleration.x; 
    double accelerationY = -acceleration.y; 
    double currentRawReading = atan2(accelerationY, accelerationX); 
    [self.sw1 setTransform:CGAffineTransformMakeRotation((CGFloat) -currentRawReading)]; 

} 

回答

0

CGAffineTransformMakeRotation預計弧度,所以如果你從currentRawReading加上或減去M_PIsw1應該旋轉180°以上。