Search code examples
iphoneiosuideviceorientationnsstatusbar

device Orientation to statusBar Orientation changes


I have created a device orientation listener to catch when the device is rotated, like so

[[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(jumpBarButtonPosition)
                                                 name:@"UIDeviceOrientationDidChangeNotification" object:nil];

however inside the jumpBarButtonPosition method I have changed from using UIDeviceOrientation to statusBarOrientation, so I am woundering what I could replace UIDeviceOrientationDidChangeNotification with in order to only receive notifications about the statudBarOrientation changes.


Solution

  • Don't type it as a string:@"UIDeviceOrientationDidChangeNotification" use:

    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(jumpBarButtonPosition)
                                                 name:UIDeviceOrientationDidChangeNotification object:nil];