I'm working on a custom keyboard for iOS which will have its own search field (similarly implemented by PopKey).
My keyboard's textfield is able to take the focus with becomeFirstResponder
and I'm able to give it up by using resignFirstResponder
. However after I resign focus, the host app has a difficult time retaking focus despite touching the form. The app's textfield will still show the text cursor blinking.
Any ideas? Thanks
The solution is a hack, as of right now you can't really give the host app its focus back.
Subclass a UITextField
and on its delegate implement
textFieldShouldBeginEditing
by returning NO
.
Add a BOOL
property isSelected
that gets set to YES
in touchesBegan
(not to be confused with the default selected
property)
keyPressed
method, if searchField.isSelected
, manipulate the searchField.text
. Else, manipulate textDocumentProxy
like normal.clear
button and method that wipes searchField.text
and searchField.isSelected
, allowing any further keystrokes to return to the textDocumentProxy