title: Custom UIWindows do not rotate correctly in iOS 8
body: <p>Get your application into landscape mode and execute the following code:</p>
  
  <pre><code>UIWindow *toastWindow = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
  toastWindow.hidden = NO;
  toastWindow.backgroundColor = [[UIColor cyanColor] colorWithAlphaComponent:0.5f];
  
  dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
      [toastWindow removeFromSuperview];
  });
  </code></pre>
  
  <p>In iOS 7 you will get a transparent blue overlay on top of the entire screen that disappears after 5 seconds. In iOS 8 you will get a transparent blue overlay that covers a little over half the screen</p>
  
  <p><img src="https://i.stack.imgur.com/8r0tj.png" alt="device screenshot"></p>
  
  <p>This obviously has something to do with the change Apple did in iOS 8 where the screen coordinates are now interface oriented instead of device oriented but in true Apple fashion they seem to have left a myriad of bugs in landscape mode and rotation.</p>
  
  <p>I can "fix" this by checking if the device orientation is landscape and flip the width and height of the main screen bounds but that seems like a horrible hack that is going to break when Apple changes everything again in iOS 9.</p>
  
  <pre><code>CGRect frame = [[UIScreen mainScreen] bounds];
  
  if (UIInterfaceOrientationIsLandscape([UIDevice currentDevice].orientation))
  {
      frame.size.width = frame.size.height;
      frame.size.height = [[UIScreen mainScreen] bounds].size.width;
  }
  
  UIWindow *toastWindow = [[UIWindow alloc] initWithFrame:frame];
  toastWindow.hidden = NO;
  toastWindow.backgroundColor = [[UIColor cyanColor] colorWithAlphaComponent:0.5f];
  
  dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
      [toastWindow removeFromSuperview];
  });
  </code></pre>
  
  <p>Has anyone been experiencing this problem and come across a better, less brittle solution?</p>
  
  <p><strong>EDIT:</strong> I know I could just use a UIView and add it to the key window but I would like to put something on top of the status bar.</p>