2010-02-22 77 views
0

如何检测iPhone角度? 我的意思是说,当iPhone是直的(即)HomeButton在底部,所以如何从UIAccelerometer法检测90度。UIA加速度计检测角度问题

CGFloat RadiansToDegrees(CGFloat radians) {return radians * 180/M_PI;}; 

我尝试RadiansToDegrees(ATAN2(acceleration.y,acceleration.x)),但它给-90度角

任何helpwould所理解的。

回答

2

如果只是招牌的问题,使用

return - RadiansToDegrees(atan2(acceleration.y, acceleration.x));