在 iPhone UiWebViews 中抑制键盘
我有一个使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看来这是不可能的,我进一步研究了一下,这很清楚。我不想接受错误的答案,所以我想我自己回答这个问题并说:做不到。
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.
如果您只想让 textField 执行除显示键盘操作之外的正常操作,您可以子类
UITextField
并覆盖touchesBegan/Moved/Ended
,只需调用 supertouchesBegan/已移动/结束
并添加隐藏键盘的附加代码,如果您有对键盘的引用(您可以自己弄清楚如何操作),请调用该方法:[keyboard resignFirstResponder],您可以尝试对
UITextField
类进行分类,这样您就可以获得对键盘的引用(如果它是私有的) - 但不推荐,因为分类可能会破坏我们的项目设计,但如果您只是需要它为了唯一的目的,尝试一下。希望有帮助。if you just want the textField do normal things except the showing keyboard action, you could subclass
UITextField
and overwrite thetouchesBegan/Moved/Ended
, just call supertouchesBegan/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 theUITextField
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.