在 iPhone UiWebViews 中抑制键盘

发布于 2024-09-01 20:56:20 字数 118 浏览 5 评论 0原文

我有一个使用 UiWebViews 的应用程序,并且我不需要在此类视图中显示文本字段的键盘。我提供了自己的按钮,用于插入字段允许的有限类型的文本,但我还需要允许粘贴(我将过滤粘贴的内容)并调整光标位置。有办法做到这一点吗?

I have an app that uses UiWebViews, and I need to not show the keyboard for a text field within such a view. I provide my own buttons that insert the limited sorts of text the field allows, but I also need to allow pasting (I will filter what gets pasted) and adjusting the cursor position. Any way to do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

像你 2024-09-08 20:56:20

看来这是不可能的,我进一步研究了一下,这很清楚。我不想接受错误的答案,所以我想我自己回答这个问题并说:做不到。

It looks like this can't be done, I've researched it further and that's pretty clear. I don't want to accept a wrong answer, so I figured I'd just answer this myself and say: can't be done.

巨坚强 2024-09-08 20:56:20

如果您只想让 textField 执行除显示键盘操作之外的正常操作,您可以子类 UITextField 并覆盖 touchesBegan/Moved/Ended,只需调用 super touchesBegan/已移动/结束并添加隐藏键盘的附加代码,如果您有对键盘的引用(您可以自己弄清楚如何操作),请调用该方法:[keyboard resignFirstResponder],您可以尝试对 UITextField 类进行分类,这样您就可以获得对键盘的引用(如果它是私有的) - 但不推荐,因为分类可能会破坏我们的项目设计,但如果您只是需要它为了唯一的目的,尝试一下。希望有帮助。

if you just want the textField do normal things except the showing keyboard action, you could subclass UITextField and overwrite the touchesBegan/Moved/Ended, just call super touchesBegan/Moved/Ended and add additional code which would hide the keyboard, if you have a reference to the keyboard ( you may figure it out urself how-to ), call the method : [keyboard resignFirstResponder], you may try to Category the UITextField class so you would have the reference to the keyboard ( if it's private ) - but not recommended because categorying may break our project design, but if you just need it for the only purpose, give it a try. Hope it helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文