title: UINavigationbar loses set image on rotation
body: <p>I have an app which starts with a root <code>UINavigationController</code>. This controller then pushes and pops various other <code>UIViewControllers</code> - that all works fine.</p>
  
  <p>My app has a custom graphic for the <code>navigationController.navigationBar.backgroundImage</code>. There is one image for the iPhone platform. There are two images for the iPad platform - one for portrait, one for landscape. The iPad is the platform of issue as it rotates, the iPhone platform is portrait only.</p>
  
  <p>I had already written code in <code>-(void)willRotateToInterfaceOrientation:</code> to detect the rotation, and set the <code>navigationBar.backgroundImage</code> to the correct orientation graphic, if the platform is iPad.</p>
  
  <p>In the iPad 5.0 simulator - it works fine; rotating the iPad on screen results in the correct navigationBar graphic regardless of orientation.</p>
  
  <p><strong>On the device - it doesn't work</strong> - The graphic appears correctly on iPad device launch in portrait. When I rotate to landscape, the navigationBar changes to a standard grey one. When I rotate back the grey 'sticks'.</p>
  
  <p>I have tried calling <code>setNeedsDisplay</code> - no change.</p>
  
  <p>I have tried setting <code>navigationBar.tintColor = [UIColor clearColor]</code> - no change.</p>
  
  <p>I have checked the filenames of the graphics in the code are identical to the actual filenames - they are.</p>
  
  <p>Code for rotation:</p>
  
  <pre><code>-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
  if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
      return YES; }
  return (interfaceOrientation == UIInterfaceOrientationPortrait);
  </code></pre>
  
  <p>}</p>
  
  <pre><code>-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
  if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
      if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft || toInterfaceOrientation == UIInterfaceOrientationLandscapeRight) {
          UIImage *titleImage = [UIImage imageNamed:@"StandardHeaderIpadLandscape"];
          self.navigationController.navigationBar.tintColor = [UIColor clearColor];
          [self.navigationController.navigationBar setBackgroundImage:titleImage forBarMetrics:UIBarMetricsDefault];
          self.navigationController.view.backgroundColor = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"StandardBackgroundiPadLandscape.png"]];
          [self.navigationController.navigationBar setNeedsDisplay];
      } else {
          UIImage *titleImage = [UIImage imageNamed:@"StandardHeaderIpadPortrait"];
           self.navigationController.navigationBar.tintColor = [UIColor clearColor];
          [self.navigationController.navigationBar setBackgroundImage:titleImage forBarMetrics:UIBarMetricsDefault];
          self.navigationController.view.backgroundColor = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"StandardBackgroundiPad.png"]];
          [self.navigationController.navigationBar setNeedsDisplay];
      }
  }
  </code></pre>
  
  <p>}</p>