The dictation button for UITextView generates extra keyboard notifications

I need to scroll my view up to make room for the keyboard since as far as I know there's no way to do this automatically. I'm relying on keyboard notifications to know when to scroll my view up and down.


My scheme works perfectly fine with UITextField, but I discovered a bug on a view containing a UITextView. If you hit the dictation button, ANOTHER UIKeyboard notification IS generated for the keyboard that's already showing. I can hack a fix, but I'd really like to be able to detect when dictation-generated notifications are being sent so they can be ignored.

Answered by Marvin Bellamy in 81381022

My resolution to this was to use a CGFloat field to store the keyboard shift distance initially set to 0.0. On the first call, I set it to the shift distance in my keyboardWillShow callback. If it's already non-zero, I ignore the next call.


Then in keyboardWillHide, I set it to 0.0 if non-zero. It'll have to do until this is fixed in the OS.

Accepted Answer

My resolution to this was to use a CGFloat field to store the keyboard shift distance initially set to 0.0. On the first call, I set it to the shift distance in my keyboardWillShow callback. If it's already non-zero, I ignore the next call.


Then in keyboardWillHide, I set it to 0.0 if non-zero. It'll have to do until this is fixed in the OS.

The dictation button for UITextView generates extra keyboard notifications
 
 
Q