vsl vsl - 5 months ago 27
Objective-C Question

How dismiss keyboard without losing focus. or at least show cursor

How dismiss keyboard without losing focus. or at least show cursor.

I have speech recognition button and textview.
User can type with keyboard or use speech recognition.
But I want to dismiss keyboard while user using speech recognition.

Currently, I am resigning responder but it hides cursor on textView.

vsl vsl
Answer

I solved these with following steps:

1) I subclassed UIWindow and override sendEvent Inside: I check for tap presence and do following if view is intended one

UITextView *view=(UITextView*)touch.view;
view.input=nil;
[view reloadInputViews];

This way I ensure that on tap Keyboard will appear for my textview

2) For my speech recognition button click I do following to hide default keyboard

myview.input=[[UIView alloc]init];
 [myview reloadInputViews];
Comments