Danchez Danchez - 1 year ago 237
Objective-C Question

iOS Keyboard (inside UIRemoteKeyboardWindow) is Not Shown When UITextField Becomes First Responder in Touch ID Completion Block (iOS 10 only)

I've recently discovered a problem in my app that only seems to occur in the betas of iOS 10 where the iOS system keyboard does not display when programmatically triggering a text field to become first responder inside of a completion handler -- specifically the completion handler I get back from a Touch ID attempt.

The crazy part of this issue is, even though the keyboard is not shown, the area on the iPhone where the keyboard normally would be is still responding to touch inputs as if the user is typing on the keyboard!

After doing a lot of investigation and debugging into the issue, I stumbled across the fact that the

property is set to
on the private
that gets created after
is invoked on the text field. In other situations where I bring up the keyboard and output the value of that
property, it's set to

Has anybody else run into this problem in iOS 10 (as of Beta 6)? If so, anybody found a solution to this? I tried manually setting the
value to
on the window instance but that had no effect on it. I'm pretty much grasping at straws at this point.


Here's the output of the windows from the
instance when the text field becomes first responder outside of the Touch ID completion handler:

becomeFirstResponder outside of Touch ID completion

And when it becomes the first responder inside the Touch ID handler:

becomeFirstResponder inside of Touch ID completion

First Update

So I did not consider the
being done on the main thread before that some have pointed out, but unfortunately, it did not resolve the issue -- however, I did make some additional discoveries. The
window issue seems to stem from outputting the details of the
instance's windows immediately after issuing the
action. After doing that, I set a breakpoint on the
editing callback and proceed to interact with the keyboard (that is invisible) -- and when I output the window details, it doesn't seem like the
property is ever set to
(which can possibly rule out that property being set as the cause of the issue), but I still have an invisible keyboard! I started debugging the view hierarchy and below is a screenshot of what it looks like when I examine the keyboard window:

Debugging Keyboard Window #1

Debugging Keyboard Window #2

Hopefully you guys can what I just noticed which is the keys are present but there appears to be some white view blocking them from sight. The thing is, I don't even see those white views on my app screen. I just see what normally sits behind the keyboard when it's present.

Answer Source

As a temporary workaround, call becomeFirstResponder after a delay fixed this, however, not happy with the hacky solution.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download