title: Keyboard doesn't receive taps after app has been in the background
body: <p>I've just shipped an iOS 8 update to my crossword app, Four Down, and have started receiving reports that it gets into a state where answers can't be entered as tapping the keyboard dismisses it rather than entering a letter.</p>
  
  <p>After some investigation, it reliably gets into this state whenever the app is put into the background and then becomes active again. Quitting the app and relaunching it fixes the problem until it's next brought back from the background.</p>
  
  <p>When the problem's occurring it appears that things are stacked in the wrong order for touch detection (but not visually) as the view visually beneath the keyboard is receiving the touch. I believe the problem's iOS 8 specific.</p>
  
  <p>In an attempt to diagnose the problem, I've subclassed UIApplication and overridden sendEvent so that I can examine the events being sent. When the problem's occurring, the event is assigned to the wrong UIWindow. Here's the event when it's working:</p>
  
  <pre><code>2014-10-04 07:56:57.998 four-down[95709:8557144] &lt;UITouchesEvent: 0x7fe838f07350&gt; timestamp: 1.29014e+06 touches: {(
      &lt;UITouch: 0x7fe83a11abf0&gt; phase: Began tap count: 1 window: &lt;UITextEffectsWindow: 0x7fe838d549e0; frame = (0 0; 320 568); opaque = NO; gestureRecognizers = &lt;NSArray: 0x7fe838d556d0&gt;; layer = &lt;UIWindowLayer: 0x7fe838d54ea0&gt;&gt; view: &lt;UIKeyboardLayoutStar: 0x7fe838da6a90; frame = (0 0; 320 216); opaque = NO; layer = &lt;CALayer: 0x7fe838db3cc0&gt;&gt; location in window: {243, 388.5} previous location in window: {243, 388.5} location in view: {243, 36.5} previous location in view: {243, 36.5}
  )}
  </code></pre>
  
  <p>And here's the event when it's not working:</p>
  
  <pre><code>2014-10-04 07:58:08.952 four-down[95709:8557144] &lt;UITouchesEvent: 0x7fe838f07350&gt; timestamp: 1.29021e+06 touches: {(
      &lt;UITouch: 0x7fe83a5c91a0&gt; phase: Began tap count: 1 window: &lt;UIWindow: 0x7fe83a33f3f0; frame = (0 0; 320 568); gestureRecognizers = &lt;NSArray: 0x7fe83a340010&gt;; layer = &lt;UIWindowLayer: 0x7fe83a304160&gt;&gt; view: &lt;CrosswordInteractiveView: 0x7fe83a555920; frame = (0 65; 310 310); gestureRecognizers = &lt;NSArray: 0x7fe83a54d4e0&gt;; layer = &lt;CALayer: 0x7fe83a544df0&gt;&gt; location in window: {241.5, 379} previous location in window: {241.5, 379} location in view: {236.5, 250} previous location in view: {236.5, 250}
  )}
  </code></pre>
  
  <p>Note the different window on the two events. UITextEffectsWindow is the window containing the keyboard, and UIWindow is the main application window. I've checked the windowLevel property on each window. It's the same in both cases: 1.0 for the keyboard window and 0.0 for the main application window.</p>
  
  <p>What, if anything, am I doing wrong? Given that it works on iOS 7, it feels like an iOS bug but perhaps there's a new iOS 8 API that I should be calling? If there's not, I'd welcome suggestions for a workaround</p>