views:

203

answers:

1

Hello All,

How to detect the iPhone angle? I mean that when iPhone is straight (i.e) HomeButton is in bottom part, so how to detect 90 Degree from UIAccelerometer Method.

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

i try RadiansToDegrees(atan2(acceleration.y, acceleration.x)) but it gives -90 degree angle

any helpwould be appreciated.

+1  A: 

If it's just an issue of sign, use

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