在UIWebview上编辑文本字段时,键盘不显示 [英] Dimiss keyboard when editing textfield on UIWebview

查看:54
本文介绍了在UIWebview上编辑文本字段时,键盘不显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在UIWebview上打开一个网页,该页面上有一个文本字段和一个用于输入密码的虚拟键盘。但是,在编辑文本字段时,iPhone虚拟键盘也会出现。
我想关闭iPhone键盘,同时继续编辑文本字段。我尝试了以下操作,但没有用。

I'm opening a web page on UIWebview and this page has a textfield and a virtual keyboard the to enter password. But when edit the textfield iPhone virtual keyboard appears as well. I wanted to dismiss iPhone keyboard and on the same time continue editing the textfield. I have tried the following but it did not work.

[webView stringByEvaluatingJavaScriptFromString:@"document.activeElement.blur()"];

还尝试注册键盘通知,以便我可以放弃键盘,但没有成功。我将不胜感激有关如何实现这一目标的任何想法。提前致谢。

And also tried to register for Keyboard notification so I can dimiss the keyboard but did not succeed. I would appreciate any ideas about how to achieve this. Thanks in advance.

[[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector (keyboardDidShow:)
                                                 name: UIKeyboardDidShowNotification object:nil];



-(void) keyboardDidShow: (NSNotification *)notif 
{
// I want to dismiss the keyboard 
}


推荐答案

尝试一下

[webView endEditing:YES]

您如果上述解决方案无效,也可以尝试此链接-在UIwebView中隐藏键盘

You also can try this link if above solution does not work - Hide keyboard in UIwebView

这篇关于在UIWebview上编辑文本字段时,键盘不显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆