Search code examples
iosuitextfielduisearchbaruikeyboard

How to handle keyboard mic button event on iPhone


I have this UISearchBar sits on top of self.view. With the default keyboard shown when it became first responder, I wonder if there's any way to pick up a touch event of the microphone button. Any help would be greatly appreciated.

enter image description here


Solution

  • You are viewing this microphone icon because your iPhone dictation is switched on under Settings>General>Keyboard>Dictation or Settings-->General-->Siri.

    I think you can use text input mode to identify which input mode is currently going on.

    UITextInputCurrentInputModeDidChangeNotification
    

    Reference - https://developer.apple.com/documentation/uikit/uitextinputmode?language=objc