因此,我获得了以下代码来插入文本:
func insert(text: String) {
(textDocumentProxy as UIKeyInput).insertText(text)
}但是我怎么才能真正把它发送到聊天窗口呢?
发布于 2017-02-15 21:16:10
如果您希望访问在UIInputViewController中输入的所有文本,以下代码可能会有所帮助:
var totalText = "" // complete text entered
if let before: String = self.textDocumentProxy.documentContextBeforeInput {
totalText += before
}
if let after: String = self.textDocumentProxy.documentContextAfterInput {
totalText += after
}现在您已经输入了完整的文本,您可以将其发送到聊天窗口。如果这就是你要找的,这里有一些限制我可以分享。请让我知道
编辑
要将文本发送到whatsapp,您需要按send button,它是outside custom keyboard extension。如果您想将文本输入到whatsapp的UITextView中,那么这样做非常简单。但是,custom keyboard extension不能控制whatsapp的发送按钮
https://stackoverflow.com/questions/42249704
复制相似问题