title: iOS get Keyboard Window
body: <p>So in iOS 7 I always got the Keyboard Window like this:</p>
  
  <pre><code>- (UIView *)keyboardView
  {
      UIWindow* tempWindow;
  
      //Because we cant get access to the UIKeyboard throught the SDK we will just use UIView.
      //UIKeyboard is a subclass of UIView anyways
      UIView* keyboard;
  
      NSLog(@"windows %d", [[[UIApplication sharedApplication]windows]count]);
  
      //Check each window in our application
      for(int c = 0; c &lt; [[[UIApplication sharedApplication] windows] count]; c ++)
      {
          //Get a reference of the current window
          tempWindow = [[[UIApplication sharedApplication] windows] objectAtIndex:c];
  
          //Get a reference of the current view
          for(int i = 0; i &lt; [tempWindow.subviews count]; i++)
          {
              keyboard = [tempWindow.subviews objectAtIndex:i];
              NSLog(@"view: %@, on index: %d, class: %@", [keyboard description], i, [[tempWindow.subviews objectAtIndex:i] class]);
              if([[keyboard description] hasPrefix:@"(lessThen)UIKeyboard"] == YES)
              {
                  //If we get to this point, then our UIView "keyboard" is referencing our keyboard.
                  return keyboard;
              }
          }
  
          for(UIView* potentialKeyboard in tempWindow.subviews)
              // if the real keyboard-view is found, remember it.
              if ([[[UIDevice currentDevice] systemVersion] floatValue] &gt;= 8.0) {
                  if([[potentialKeyboard description] hasPrefix:@"&lt;UILayoutContainerView"] == YES)
                      keyboard = potentialKeyboard;
              }
              else if ([[[UIDevice currentDevice] systemVersion] floatValue] &gt;= 3.2) {
                  if([[potentialKeyboard description] hasPrefix:@"&lt;UIPeripheralHost"] == YES)
                      keyboard = potentialKeyboard;
              }
              else {
                  if([[potentialKeyboard description] hasPrefix:@"&lt;UIKeyboard"] == YES)
                      keyboard = potentialKeyboard;
              }
      }
  
  
      NSLog(@"view: %@, on index: %d", [keyboard description]);
      return keyboard;
  }
  </code></pre>
  
  <p>But in the iOS 8 beta 1 &amp; 2 the window/view that is returned is the main App window. Any idea what is the the problem in my code? On my test device with iOS 7 it works great...</p>