I want to find out when the status bar rotates. Receiving a screen rotation notification can confuse matters with orientations such as 'face up' and 'face down'. Managing rotation based on the orientation of the status bar is therefore the simplest and cleanest way of doing it. How do i get a notification when the orientation changes?
You need to register for the UIApplicationDidChangeStatusBarOrientationNotification
notification.
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(statusBarOrientationChange:) name:UIApplicationDidChangeStatusBarOrientationNotification object:nil];
- (void)statusBarOrientationChange:(NSNotification *)notification {
UIInterfaceOrientation orient = [notification.userInfo[UIApplicationStatusBarOrientationUserInfoKey] integerValue];
// handle the interface orientation as needed
}
Note that this approach never results in the "face up" or "face down" device orientations since this only deals with interface orientations.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With