Aggressor
Aggressor

Reputation: 13551

Get Instance of iOS Keyboard Without First Responder

My application uses Cordova so a number of functions are performed in the webview.

There is an object in one of my webviews that brings up the keyboard.

All the documentation and SO answers on changing the keyboard involve setting the values of the first responder. My problem is, on the native side, I do not have the first responder.

So my question is:

Can I get access to the keyboard object without the first responder, and if so how?

Swift/Obj-c answers welcome

Upvotes: 0

Views: 139

Answers (1)

Connor
Connor

Reputation: 64674

You can use UIReturnKeyType for native controls, but unfortunately there is no way to control the return key for text fields within a webview. You might be able to figure out some sort of hacky solution though.

One idea is to manually modify the keyboard views. There's an Apache plugin that uses this to hide the form accessory bar on keyboards. You can see how they do it here. You would have to find the return key's view instead of the form bar though. Of course this isn't supported and is likely to break at some point.

Another option might be to use swizzling to modify UIWebView to use the UIReturnKeyType you want. You'd have to look into dumping the headers to find a possible starting point. This option also has the potential to break along with a chance Apple rejects your app.

Upvotes: 1

Related Questions