0
votes

I wanna show a full-screen Landscape view whenever the user rotates the iOS device from portrait to landscape, where the portrait view is a view within a TabBar and NavigationController.

However, willRotateToInterfaceOrientation:duration: is never called. I tested also to add the ViewController as Observer of UIDeviceOrientationDidChangeNotification events, but this notification is called also with undefined orientation.

What would be the best and easiest way for the given task?

1

1 Answers

1
votes

There are also UIApplicationWillChangeStatusBarOrientationNotification and UIApplicationDidChangeStatusBarOrientationNotification notifications.

The userInfo dictionary contains an NSNumber object that encapsulates a UIInterfaceOrientation value. Use UIApplicationStatusBarOrientationUserInfoKey to access this value

    [[NSNotificationCenter defaultCenter] addObserver:self 
                                             selector:@selector(didRotate:)
                                                 name:UIApplicationDidChangeStatusBarOrientationNotification 
                                               object:nil];

- (void) didRotate:(NSNotification *)notification{   
    NSNumber *num = [[notification userInfo] objectForKey:@"UIApplicationStatusBarOrientationUserInfoKey"];
    NSLog(@"%d", [num intValue]);
}