Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Status bar rotation notification

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?

like image 420
Andrew Avatar asked Feb 18 '13 17:02

Andrew


1 Answers

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.

like image 118
rmaddy Avatar answered Sep 28 '22 04:09

rmaddy