You can use [[UIApplication sharedApplication] statusBarOrientation]
to detect device orientation.
This method returns orientation value for all cases but if you use
[[UIDevice currentDevice]orientation]
sometimes you get unknown orientation.
I hope that works for you.