I have a UIView
class which I add to my main UIViewController
and I need to check the orientation of the device (iPad) at the launch of the app, in the viewDidLoad
method. However because the class is a UIView
(not UIViewController
) I can't use methods such as willAnimateRotationToInterfaceOrientation
.
So I attempted to use this in my UIView
class:
if (([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeLeft) ||
([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeRight)) {
However, testing with some breakpoints, whatever the orientation is, the of statement is never called, its skips right passed it. So what do you suggest I do to overcome this issue?
I need to somehow detect the orientation from the UIView class.
Thanks.