title: iOS orientation change not working also UIDeviceOrientationDidChangeNotification not received
body: <p>I am quite new to iOS and I am trying desperately to get orientation changes working in my app. After researching here's what I do:</p>
  
  <p>In my app I have a NavigationController managing seven UIViewController subclasses.</p>
  
  <p>In the projects summary tab I activated all 4 device orientations.</p>
  
  <p>Each UIViewcontroller subclass has a xib file, all xib files have "autoresize subviews" activated. </p>
  
  <p>The UIViewController subclasses all have:  </p>
  
  <pre><code>    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
  {
      return (interfaceOrientation == UIInterfaceOrientationPortrait || 
              interfaceOrientation == UIInterfaceOrientationLandscapeLeft ||
              interfaceOrientation == UIInterfaceOrientationLandscapeRight );
  }
  </code></pre>
  
  <p>they also all have:   </p>
  
  <pre><code>- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
  </code></pre>
  
  <p>and:</p>
  
  <pre><code>- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
  </code></pre>
  
  <p>implemented with an NSLog(...) statements (never printed, debugger also never entering these methods).</p>
  
  <p>Also I was trying to use:</p>
  
  <pre><code>    [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
  
  BOOL getOrientationUpdates = [[UIDevice currentDevice] isGeneratingDeviceOrientationNotifications];
  NSLog(@"will receive orientation notifications: %@", getOrientationUpdates?@"YES":@"NO");
  
  [[NSNotificationCenter defaultCenter] addObserver:self
                                           selector:@selector(orientationChanged:)
                                               name:UIDeviceOrientationDidChangeNotification
                                             object:nil];
  </code></pre>
  
  <p>with </p>
  
  <p><code>-(void)orientationChanged: (NSNotification*) notification
  {
      NSLog(@"orientationChanged");
  }</code></p>
  
  <p>and </p>
  
  <p><code>
      [[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications];
      [[NSNotificationCenter defaultCenter] removeObserver:self];</code> 
  respectively.</p>
  
  <p>when I do <code>beginGeneratingDeviceOrientationNotifications</code> etc. in the AppDelegate's <code>- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
  </code> method, orientationChanged: is called once on startup but never again however I rotate the device, when I do it in one of the UIViewController subclasses it is never called!</p>
  
  <p>So far, all I want to achieve is getting orientation notifications to rotate an UIImageView and UIImage (without any layout changes in the different orientations).</p>
  
  <pre><code>UIDeviceOrientation o = [UIDevice currentDevice].orientation;
  </code></pre>
  
  <p>always returns <code>UIDeviceOrientationPortrait</code></p>
  
  <p>It might be that I missed something in the docs or on stackoverflow, but I obviously cannot figure out what I need to do/add to get it working in my setup. also I am quite new to stackoverflow, so I hope my post is not violating any platform conventions.</p>
  
  <p>Any help/hints are greatly appreciated. Thank you so much!</p>
  
  <p>EDIT: 
  getOrientationUpdates is always YES, which appears strange to me as the notification callback selector is never called when I rotate it!</p>
  
  <p>EDIT: in my AppDelegate's didFinishLaunchingWithOptions I am doing:</p>
  
  <pre><code>    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
  self.regScreenController = [[RegistrationScreenController alloc] initWithNibName:@"RegistrationScreenController" bundle:nil];
  
  navCtrl = [[UINavigationController alloc]initWithRootViewController:self.regScreenController];
  
  [navCtrl setNavigationBarHidden:YES];
  self.window.rootViewController = self.regScreenController;
  [self.window addSubview:navCtrl.view];
  [self.window makeKeyAndVisible];
  return YES;
  </code></pre>