In my objects init method
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(didRotate:)
name:@"UIDeviceOrientationDidChangeNotification"
object:nil];
did Rotate Method
- (void) didRotate:(NSNotification *)notification {
NSLog(@"rotate notification");
//MA_MobileAppDelegate *appDelegate = (MA_MobileAppDelegate *)[[UIApplication sharedApplication] delegate];
//UIInterfaceOrientation orientation = appDelegate.tabBarController.interfaceOrientation;
UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
For some reason the didRotate seems to be called before the actual rotation. Thus when I try to get the current/final rotation I get the last one. There is only 1 view controller that this doesn't seem to be the case. Any ideas what I'm doing wrong?
I had to delay my code
[self performBlock:^(id sender) {
//rotation code
} afterDelay:0.1f];
The short delay is all that was needed to give UIApplication the time to update the statusbar orientation property :(