简体   繁体   English

在没有第一响应者的情况下获取iOS键盘实例

[英]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.

相关问题 IOS在没有辞职急救人员的情况下解雇/显示键盘 - IOS Dismiss/Show keyboard without Resigning First Responder iOS 11 - 成为第一响应者而不是打开键盘 - iOS 11 - Become First Responder not opening the keyboard iOS-UIButton成为打开键盘的第一响应者 - iOS - UIButton become first responder to open keyboard iOS为什么调用从uitextield中删除第一响应者会影响键盘? - iOS why calling removing the first responder from a uitextield affects the keyboard? 当UITextField成为Touch ID完成块(iOS 10)的第一响应者时,未显示iOS键盘(位于UIRemoteKeyboardWindow内部) - iOS Keyboard (inside UIRemoteKeyboardWindow) is Not Shown When UITextField Becomes First Responder in Touch ID Completion Block (iOS 10) iOS / MonoTouch:成为第一响应者 - iOS / MonoTouch: Become first responder SwiftUI iOS 应用程序在 state 更改导致键盘在工作表中辞去第一响应者时崩溃 - SwiftUI iOS app crashes when state change causes keyboard to resign as first responder while in a sheet 成为没有动画的第一响应者 - Become first responder without animation 防止键盘作为第一响应者出现在文本字段中 - Prevent keyboard to appear with a textfield as a first responder UITextField隐藏键盘但Reamin First Responder? - UITextField Hide Keyboard But Reamin First Responder?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM