UITextView似乎没有实现reloadInputViews [英] UITextView does not seem to implement reloadInputViews

查看:102
本文介绍了UITextView似乎没有实现reloadInputViews的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将自定义输入视图加载到UITextField中,我可以在UIKeyboardTypeAlphabet和UIKeyboardTypeNumberPad之间随意更改标准键盘的键盘类型。只需调用类似:

Loading a custom input view into a UITextField, I can arbitrarily change the keyboard type of the standard keyboard between UIKeyboardTypeAlphabet and UIKeyboardTypeNumberPad. Just call something like:

[editingField setKeyboardType:UIKeyboardTypeNumberPad];
[editingField reloadInputViews];

中提琴!有你的数字键盘。

And viola! There is your number pad.

不改变这段代码,只是让editField成为UITextView而不是UITextField,它不再有效。根据文档,这些都符合UITextInput和UITextInputTraits协议。

Without changing this block of code, but just making editingField a UITextView instead of a UITextField, it no longer works. According to the docs, these are both compliant with the UITextInput and UITextInputTraits protocols.

值得一提的是,上面的代码确实工作,但只有在用户离开有问题的textView并稍后重新选择它之后。它几乎就像reloadInputViews什么都不做,然后当textView成为FirstResponder时,它会加载它的输入视图。

It is worth mentioning that the above code actually does work, but only after the user leaves the textView in question and later reselects it. It is almost like reloadInputViews does nothing, and then the textView loads its input views when it becomeFirstResponder.

我尝试了各种performSelector:等,并且无法强制解决问题。有任何想法吗?如何使UITextView服从reloadInputViews并动态更改其inputView?

I have tried all sorts of performSelector: etc and cannot force the issue. Any ideas? How do you make UITextView obey reloadInputViews and dynamically change its inputView?

推荐答案

你是否在调用之前将UITextView的inputView设置为nil? / p>

Are you setting inputView of UITextView to nil before calling?

[editingField setKeyboardType:UIKeyboardTypeNumberPad];
[editingField reloadInputViews];

这篇关于UITextView似乎没有实现reloadInputViews的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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