当用户点击UIWebView时,默认键盘如何出现? [英] How the default keyboard comes up when user taps in UIWebView?

查看:179
本文介绍了当用户点击UIWebView时,默认键盘如何出现?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在开发类似Mogok的自定义iOS浏览器。当用户点击UIWebView中的任何textinput时,我需要更改默认键盘。

I am currently developing a custom iOS browser something like Mogok. I need to change the default keyboard when user taps on any textinput in the UIWebView.

我想知道当用户点击UIWebView中的任何输入文本时系统如何显示键盘?如何获取在UIWebView中成为第一响应者的文本字段的引用?我已经做了2晚黑色:-)还没有结果: - (

I wonder how the system shows keyboard when a user taps on any input text in UIWebView? How can I get the reference of the text field which becomes first responder in UIWebView ? I have already made 2 nights black :-) No result yet :-(

任何帮助都将受到高度赞赏。

Any help would be highly appreciated.

问候
Ranjan

Regards Ranjan

推荐答案

好吧,如果你不能打败他们,请加入他们。

Well, if you can't beat them, join them.

据我所知,我试过。你不能在不使用私有类(UIWebBrowserView)的情况下更改inputView或inputAccessoryView。

As far as I know, and I tried. You can't change the inputView or the inputAccessoryView without using a private class (UIWebBrowserView).

但你可以通过UIKeyboardWillShowNotification通知检测键盘何时出现。那么,如何做一个中间人怎么样?
我意思是,像缓冲区一样使用UITextField

But you can detect when the keyboard appears, with the notification UIKeyboardWillShowNotification. So, how about do a man in the middle? I mean, use a UITextField like a buffer.

让我再解释一下。

当键盘出现时,您可以检查第一个响应者是否是UIWebView,如果是,您可以成为第一个响应者的textview。

When the keyboard appears, you can check if the first responder is the UIWebView, if it is, you can become a textview as the first responder.

做什么你赢了吗?用键盘输入的文字转到文本视图。
这没用,你会的当然,但如何改变textview的输入视图呢?怎么样?使用此 https://github.com/kulpreetchilana/Custom-iOS-Keyboards

What do you win with that? The text typed with the keyboard go to the text view. That is useless, you would say. Of course, but how about change the input view of the textview? How? With this https://github.com/kulpreetchilana/Custom-iOS-Keyboards

当用户在Web视图中书写时,您有一个自定义键盘!!!

You have a custom keyboard when the user is writing in the web view!!!

如何将textview的文本放在webview中?
简单,使用textViewDidChange和javascript将textview的文本放在内部html的输入中。

How can you put the textview's text in the webview? Easy, Put the textview's text in the input of the inner html with textViewDidChange and javascript.

- (void)textViewDidChange:(UITextView *)textView{
    NSString* script = [NSString stringWithFormat:@"document.activeElement.value = '%@';", textView.text];   
    [self stringByEvaluatingJavaScriptFromString:script];
}

我粗略地提出了这个想法的主要短语。
但是,也许我的解释很难理解。或者我的英语不好,所以我想了一下项目的样本。

I put in bold the main phrases of the idea. But, maybe my explanation is difficult to understand. Or my English is bad, so I uploade a sample project with the idea.

这篇关于当用户点击UIWebView时,默认键盘如何出现?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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