[英]Get Instance of iOS Keyboard Without First Responder
My application uses Cordova so a number of functions are performed in the webview. 我的应用程序使用Cordova,因此在Web视图中执行了许多功能。
There is an object in one of my webviews that brings up the keyboard. 我的一个Web视图中有一个对象可以调出键盘。
All the documentation and SO answers on changing the keyboard involve setting the values of the first responder. 有关更改键盘的所有说明文件和SO解答都涉及设置第一响应者的值。 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 Swift / Obj-c欢迎光临
You can use UIReturnKeyType for native controls, but unfortunately there is no way to control the return key for text fields within a webview. 您可以将UIReturnKeyType用于本机控件,但是不幸的是,无法控制Web视图中文本字段的返回键。 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.
有一个Apache插件,使用它可以隐藏键盘上的表单附件栏。 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. 另一个选择可能是使用swizzling修改UIWebView以使用所需的UIReturnKeyType。 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.
此选项还可能会破坏Apple拒绝您的应用程序的机会。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.