I have a UIWebView
that I would like to load different URLs depending on whether its portrait or landscape. How can I figure out what my current orientation is inside viewWillAppear
?
Use UIApplication's statusBarOrientation
property. You may run into problems if you use the device orientation if it is UIDeviceOrientationFaceUp
or UIDeviceOrientationFaceDown
.
Example
UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
if (UIInterfaceOrientationIsLandscape(orientation))
{
// Do something when in landscape
}
else
{
// Do something when in portrait
}