I usually enable notifications:
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
On my controllers i put:
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
[self configureOrientation:toInterfaceOrientation];
}
- (void)configureOrientation:(UIInterfaceOrientation)orientation
{
if(UIDeviceOrientationIsValidInterfaceOrientation(orientation)){
if(UIInterfaceOrientationIsLandscape(orientation)){
[self configureLandscapelView];
}else if(UIInterfaceOrientationIsPortrait(orientation)){
[self configurePortraitlView];
}
}
}
You can also get the orientation from the UIViewController itself:
UIInterfaceOrientation orientation = [self interfaceOrientation];
Or from the status bar:
[UIApplication sharedApplication] statusBarOrientation]