[英]How to Send Text in an UIInputViewController
so I've got the following code to insert text: 所以我有以下代码来插入文本:
func insert(text: String) {
(textDocumentProxy as UIKeyInput).insertText(text)
}
But how do I actually get it to send to the chat window? 但是我实际上如何将其发送到聊天窗口?
If you are looking to access all the text entered in the UIInputViewController
, the following code may help: 如果您要访问UIInputViewController
输入的所有文本,则以下代码可能会有所帮助:
var totalText = "" // complete text entered
if let before: String = self.textDocumentProxy.documentContextBeforeInput {
totalText += before
}
if let after: String = self.textDocumentProxy.documentContextAfterInput {
totalText += after
}
Now that you have complete text entered, you can send it to chat window. 现在您已经输入了完整的文本,您可以将其发送到聊天窗口。 There are some limitations here which I can share if this is what you're looking for. 如果您正在寻找这些限制,那么我可以分享一些限制。 Please let me know 请告诉我
Edit 编辑
To send text to whatsapp
, you need to press send button
which is outside
the custom keyboard extension
. 要将文本发送到whatsapp
,您需要按custom keyboard extension
outside
的send button
。 If you want to enter text into the UITextView
of whatsapp
, it is pretty straightforward to do so. 如果要将文本输入到whatsapp
的UITextView
中,则非常简单。 But, the custom keyboard extension
can't control the send button of whatsapp
但是, custom keyboard extension
无法控制whatsapp
的发送按钮
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.