Previous to iOS 9, the most reliable method of determining whether an external keyboard is connected was to listen for UIKeyboardWillShowNotification
and make a text field the first responder, as discussed in this question. The notification would fire when using the virtual keyboard, but would not fire when using an external keyboard.
However this behavior has now changed with iOS 9. UIKeyboardWillShowNotification
also fires when an external keyboard is connected, since the new keyboard toolbar is now shown.
It is still possible to detect the keyboard height and make a judgement whether it is the smaller toolbar or the larger virtual keyboard that is being shown. However this method is not reliable since the keyboard height has changed between the various beta and can't be counted on to stay the same over time.
Is there a more reliable method that can be used with iOS 9?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…