title: How to determine if iOS device's orientation *actually* changes?
body: <p>I am writing this code to make some changes to how my app is laid out depending on if it is in landscape or portrait mode. I have set up the app to get a notification on the orientation changing like this:</p>
  
  <pre><code>[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receivedRotate:) name:UIDeviceOrientationDidChangeNotification object:NULL];
  </code></pre>
  
  <p>And then defining <code>receivedRotate:</code></p>
  
  <pre><code>-(void) receivedRotate: (NSNotification*) notification {
      UIDeviceOrientation interfaceOrientation = [[UIDevice currentDevice] orientation];
  
      // ... do something
  }
  </code></pre>
  
  <p>However, <code>UIDeviceOrientationDidChangeNotification</code> is called whenever the device is moved slightly. E.g., the UIDeviceOrientation can be any of the following:</p>
  
  <pre><code>UIDeviceOrientationPortrait,
  UIDeviceOrientationPortraitUpsideDown,
  UIDeviceOrientationLandscapeLeft,
  UIDeviceOrientationLandscapeRight,
  UIDeviceOrientationFaceUp,
  UIDeviceOrientationFaceDown
  </code></pre>
  
  <p>This is great but I just want to know if the device orientation is in portrait or landscape, and I also only want to run this code when the orientation actually changes - from portrait to landscape or vice-versa. If they turn the phone all the way around, it is still in landscape mode - just a different form of landscape mode. What's the ideal way to make sure that my rotation code only runs when it is necessary?</p>