iOS Calc device orientation use accelerometer
blog :http://blog.sallarp.com/iphone-accelerometer-device-orientation/
float x = -accelerometerData.acceleration.x;
float y = accelerometerData.acceleration.y;
float angle = atan2(y, x);
if(angle >= -2.25f && angle <= -0.75f) {
currentOrientation = UIInterfaceOrientationPortrait;
} else if(angle >= -0.75f && angle <= 0.75){
currentOrientation = UIInterfaceOrientationLandscapeRight;
} else if(angle >= 0.75f && angle <= 2.25f) {
currentOrientation = UIInterfaceOrientationPortraitUpsideDown;
} else if(angle <= -2.25f || angle >= 2.25f) {
currentOrientation = UIInterfaceOrientationLandscapeLeft;
}