title: How to properly dismiss a UIAlertView programmatically in iOS 7?
body: <p>When my app enters the background, my modally presented view controller dismisses an alert view like so...</p>
  
  <pre><code>// called when view controller receives a UIApplicationDidEnterBackgroundNotification
  - (void)applicationDidEnterBackground:(NSNotification *)notification
  {
      if (self.alertView) {
          [self.alertView dismissWithClickedButtonIndex:0 animated:NO];
          self.alertView = nil;
      }
  }
  </code></pre>
  
  <p>When my app returns to the foreground without having been terminated, the alert view is gone. However, the bar button items in the navigation bar (from a UINavigationController) are still dimmed as if the alert view were still displayed. </p>
  
  <p>Moreover, dismissing the modal view controller (by tapping a dimmed bar button item) reveals that the bar button items for the presenting view controller are also dimmed. The bar buttons items are functional, but they remain dimmed. </p>
  
  <p>So how do I un-dim the bar button items? Or, how do I properly dismiss an alert view programmatically in iOS 7 in response to the app entering the background?</p>
  
  <p>The <em>iOS 7 UI Transition Guide</em> states the following:</p>
  
  <blockquote>
    <p>When an alert or action sheet appears, iOS 7 automatically dims the tint color of the views behind it. To respond to this color change, a custom view subclass that uses tintColor in its rendering should override tintColorDidChange to refresh the rendering when appropriate.</p>
  </blockquote>
  
  <p>My navigation bars and bar button items are not custom views; I did not subclass them. I created the navigation bars in storyboard with their default attributes (same with the bar button items). So there's no place for me to override tintColorDidChange.</p>
  
  <p>All of my views use the default value for their tintColor property.</p>
  
  <p>I have tried re-seting the tint color to the default value without success:</p>
  
  <pre><code>if (self.alertView) {
          [self.alertView dismissWithClickedButtonIndex:0 animated:NO];
          self.view.tintColor = nil;
          self.view.window.tintColor = nil;
          self.alertView = nil;
      }
  </code></pre>
  
  <p>I have also tried re-seting the tint color in the view controller's viewDidAppear: without success.</p>
  
  <p>I also tried setting the main view's tintAdjustmentMode to "normal" without success:</p>
  
  <pre><code>if (self.alertView) {
      [self.alertView dismissWithClickedButtonIndex:0 animated:NO];
      self.alertView = nil;
  
      self.view.tintAdjustmentMode = UIViewTintAdjustmentModeNormal;
  }
  </code></pre>
  
  <p>By the way, if the the app was terminated while in the background, the app relaunches with the bar button items having the correct tint (i.e., un-dimmed).</p>